170 likes | 425 Views
Common Type System. A chic type, a rough type, an odd type - but never a stereotype Jean-Michel Jarre. Review & Context. Types are defined by CLR, hence it is same across languages Two phases of .Net learning Basics – CLR, types, Language syntax VB.Net or C#
E N D
Common Type System • A chic type, a rough type, an odd type - but never a stereotype • Jean-Michel Jarre More Types & C#
Review & Context • Types are defined by CLR, hence it is same across languages • Two phases of .Net learning • Basics – CLR, types, Language syntax VB.Net or C# • Application – ADO.Net, ASP.Net, Windows Forms. More Types & C#
What is a Type? • The CTS provides every language running on the .NET platform with a base set of data types • Two Categories • Value Types: Value types directly contain their data. • Reference Types: Reference types store a reference to the value's memory address More Types & C#
Reference Vs. Value type int x = 10; Employee e1, e2; e1 = new Employee ("John Smith", 25, 30000); e2 = e1; x e1 “John Smith” 25 30,000 10 e2 More Types & C#
CTS More Types & C#
Built-in Value Types • Integers, floating point, Logical etc. • Refer to the table in the following page More Types & C#
Category Class name Description Visual Basic data type C# data type Integer Byte An 8-bit unsigned integer. Byte byte SByte An 8-bit signed integer. Not CLS-compliant. SByte No built-in type. sbyte Int16 A 16-bit signed integer. Short short Int32 A 32-bit signed integer. Integer int Int64 A 64-bit signed integer. Long long UInt16 A 16-bit unsigned integer. Not CLS-compliant. UInt16 No built-in type. ushort UInt32 A 32-bit unsigned integer. Not CLS-compliant. UInt32 No built-in type. uint UInt64 A 64-bit unsigned integer. Not CLS-compliant. UInt64 No built-in type. ulong More Types & C#
Category Class name Description Visual Basic data type C# data type Floating point Single A single-precision (32-bit) floating-point number. Single float Double A double-precision (64-bit) floating-point number. Double double Logical Boolean A Boolean value (true or false). Boolean bool Other Char A Unicode (16-bit) character. Char char Decimal A 96-bit decimal value. Decimal decimal Class objects Object The root of the object hierarchy. Object object String An immutable, fixed-length string of Unicode characters. String string More Types & C#
Exercise • For all the integer types find the maximum and minimum possible values. • E.g. for byte the max value is 255 • Hint: Refer to the documentation on base types such as System.Byte, System.Int32 • Use System.Convert class to convert between types. • What is Type Casting? More Types & C#
Type Members • Events • Field • Method • Property More Types & C#