Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Types Imran Rashid CTO at ManiWeber Technologies.

Similar presentations


Presentation on theme: "Data Types Imran Rashid CTO at ManiWeber Technologies."— Presentation transcript:

1 Data Types Imran Rashid CTO at ManiWeber Technologies

2 Outline What are Types? Classes & Structures

3 What are Types?

4 What are Types? In C# when we store data, we have to say what type of data we are storing A type defines what information a variable contains Variables in C# are strongly typed A typed implies minimum, maximum values Once declared, a variable’s type can’t be changed C# Built-in Data Types Logical Numeric Characters & Strings Classes & Structures Objects

5 Classes & Structures

6 object o1 = new Object(); object o2 = o1; // o2 references o1
Classes & Structures Types are represented in .NET as classes or structures Both have members: fields & methods You can create instances of either a class or structure Classes vs. Structures Structures are value types Classes are reference types int v1 = 5; int v2 = v1; // v2 is copy of v1 object o1 = new Object(); object o2 = o1; // o2 references o1

7 Classes & Structures Common Structures
Numeric and logical built-in types are structures Examples bool a true/false value int a 32-bit integer double a 32-bit floating point value decimal a 128-bit high-precision value

8 System.Boolean System.Char Classes & Structures
Logical & Character Types All .NET types are members of System You should only use type alias (fully qualified names) C# Type .NET Type Min Max bool Boolean false true char Char U+0000 U+ffff System.Boolean System.Char

9 Classes & Structures Integer Types C# Type .NET Type Min Max byte Byte
255 sbyte SByte -128 127 short Int16 -32,768 32,767 ushort UInt16 int Int32 -2, 147, 483, 648 2, 147, 483, 647 unint UInt32 4, 294, 967, 295 long Long -9.22 x 1018 9.22 x 1018 ulong Ulong 1.84 x 1019

10 Classes & Structures Floating-Point and Decimal Types
Decimal is a 128-bit, high-precision type Appropriate for currency and other financial values C# Type .NET Type Min Max Precision float Single ±1.5e-45 ±3.4e38 7 digits double Double ±5.0e-324 ±1.7e308 15-16 digits decimal Decimal -7.9 x 1028 7.9 x 1028 28-29 digits

11 C# Type .NET Type Max string String 2, 147, 483, 647*
Classes & Structures Strings Decimal is a 128-bit, high-precision type *Theoretical! Memory is more important! Mobile app where memory is small System.String is a class, not a structure C# has give a lot of tools to help with string immutability C# Type .NET Type Max string String 2, 147, 483, 647*

12 Any ?


Download ppt "Data Types Imran Rashid CTO at ManiWeber Technologies."

Similar presentations


Ads by Google