boxing
and on the other
hand, when an object type is converted to a value type, it is called
unboxing
.
object obj;
obj = 100; // this is boxing
Dynamic Type
You can store any type of value in the dynamic data type variable. Type checking for
these types of variables takes place at run-time.
Syntax for declaring a dynamic type is:
dynamic = value;
For example,
dynamic d = 20;
Dynamic types are similar to object types except that type checking for object type
variables takes place at compile time, whereas that for the dynamic type variables
takes place at run time.
String Type
The
String
Type
allows you to assign any string values to a variable. The string type
is an alias for the System.String class. It is derived from object type. The value for a
string type can be assigned using string literals in two forms: quoted and @quoted.
For example,
String str = "Tutorials Point";
19
C#
A @quoted string literal looks as follows:
@"Tutorials Point";
The user-defined reference types are: class, interface, or delegate. We will
discuss these types in later chapter.
Pointer Type
Pointer type variables store the memory address of another type. Pointers in
C# have the same capabilities as the pointers in C or C++.
Syntax for declaring a pointer type is:
type* identifier;
For example,
char* cptr;
int* iptr;
We will discuss pointer types in the chapter 'Unsafe Codes'.
20
C#
End of ebook preview
If you liked what you saw…
Buy it from our store @
https://store.tutorialspoint.com
21
Dostları ilə paylaş: |