Академический Документы
Профессиональный Документы
Культура Документы
2011
.NET
CTS
,
CLR
14.10.2011
CTS
CTS
,
,
.
( CLR),
.
14.10.2011
System.ValueType
: (struct)
(enum)
,
(sealed)
14.10.2011
(sbyte, byte, short, ushort, int,
uint, long, ulong, char)
(float, double)
decimal
bool
--
null ( , int? )
sbyte, byte, short, ushort, int, uint, long
ulong = 0
char : \x0000
float : 0.0f
double : 0.0d
decimal : 0.0m
bool : false
14.10.2011
E
= 0 E
null
= , HasValue
false,
Value
System
(
System.Object), ,
(int=23),
const
14.10.2011
sbyte
byte
short
ushort
int
uint
long
System.SByte
System.Byte
System.Int16
System.UInt16
System.Int32
System.UInt32
System.Int64
ulong
har
float
double
bool
decimal
System.UInt64
System.Char
System.Single
System.Double
System.Boolean
System.Decimal
14.10.2011
. char
16-
0 65535.
.
, :
-
char
- char
char
. decimal
128- ,
96- ,
14.10.2011
. bool
: true false
bool
,
(
)
14.10.2011
class, delegat, array, interface
null
new
( )
System.Object.
Equals(Object) ,
Object
Object
Equals(Object, Object) -- ,
Finalize --
,
14.10.2011
System.Object.
GetHashCode -- -
GetType -- Type
MemberwiseClone --
Object
ReferenceEquals -- ,
Object
ToString ,
10
14.10.2011
int i = 67;
// value type
object o = i; // i is boxed
System.Console.
WriteLine(i.ToString());
// i is boxed
11
14.10.2011
object
System.ValueType
,
,
System.Enum
,
System.Enum
.
static void Main() {
int i = 123;
object o = i;
i = 456;
System.Console.WriteLine(
i = {0}", i);
System.Console.WriteLine(
o = {0}", o);
}
12
14.10.2011
IL Disassembler
MS Windows SDK
Tools ->
IL Disassembler
File -> Open
(exe, dll)
IL
13
14.10.2011
MSIL
.method private hidebysig static
void Main(string[] args) cil
managed
{
.entrypoint
//
.maxstack 2
//
MSIL
IL_0000: nop
// 32-
IL_0001: ldc.i4.s
123
//
.locals[0]
IL_0003: stloc.0
//
.locals[0]
IL_0004: ldloc.0
14
14.10.2011
MSIL
// Int32 Object
IL_0005: box
[mscorlib]System.Int32
//
.locals[1]
IL_000a: stloc.1
// 32-
IL_000b: ldc.i4
0x1c8
IL_0010: stloc.0
MSIL
// -
IL_0011: ldstr
"i = {0}"
IL_0016: ldloc.0
// !!!!!!
IL_0017: box
[mscorlib]System.Int32
IL_001c: call
void
[mscorlib]System.Console::WriteL
ine(string, object)
IL_0021: nop
15
14.10.2011
MSIL
// -
IL_0022: ldstr
"o = {0}"
IL_0027: ldloc.1
IL_0028: call
void
[mscorlib]System.Console::WriteL
ine(string, object)
IL_002d: nop
IL_002e: ret
} // end of method Program::Main
16
14.10.2011
:
- ,
-
-.
null
System.NullReferenceException
System.InvalidCastException.
17
14.10.2011
,
(min max)
(, , )
CLR
18
14.10.2011
,
,
,
CLS
CLS
CTS
19