33. Value vs Reference Types number1 42 int number1 = 42; string name = “Gulsen Demiroz”; int number2 = number1; string text = name ; name Gulsen Demiroz number2 42 name
34.
35. Value Types Type System namespace Definition Uninitialized value short System.Int16 16 bit signed integer 0 int System.Int32 32 bit signed integer 0 long System.Int64 64 bit signed integer 0 ushort System.UInt16 16 bit unsigned integer 0 uint System.UInt32 32 bit unsigned integer 0 ulong System.UInt64 64 bit unsigned integer 0 float System.Single 32 bit real number 0.0 double System.Double 64 bit real number 0.0 decimal System.Decimal 128 bit real number 0 bool System.Boolean true or false false char System.Char 16 bit Unicode character ‘ ’ byte System.Byte 8 bit unsigned integer 0 sbyte System.SByte 8 bit signed integer 0 enum user-defined defines a type for a closed set 0 index value struct user-defined defines a compound type that consists of other types assumed value types, null reference types
36.
37.
38.
39.
40.
41. Valid Implicit Castings Type Types It Can Be Converted To sbyte short,int,float,long,double,decimal byte short,ushort,int,uint, long,ulong,float,double,decimal short int,long,float,double,decimal ushort int,uint,long,ulong,float,double,decimal int long,float,double,decimal uint long,ulong,float,double,decimal long, ulong float,double,decimal char float,double,decimal float double
42.
43.
44.
45. Convert class Method Convert.ToBoolean(string str) converts string str to bool Convert.ToByte(string str) converts string str to byte Convert.ToSByte(string str) converts string str to signed byte Convert.ToInt16(string str) converts string str to short Convert.ToUInt16(string str) converts string str to unsigned short Convert.ToInt32(string str) converts string str to integer Convert.To U Int32(string str) converts string str to unsigned integer Convert.ToInt64(string str) converts string str to long Convert.ToSingle(string str) converts string str to float Convert.ToDouble(string str) converts string str to double Convert.ToDecimal(string str) converts string str to decimal Convert.ToChar( string str) converts string str to char type
46.
47.
48.
49.
50.
51.
52.
53.
Editor's Notes
Unlike reference types, they always have a value
Talk about the result of the operations in red in the table