DataTypes in C#.Net


Equivalent Data types chart of CTS, C#.net and VB.net

Category
Class name (CTS Data type)
Visual Basic data type
  C# data type
Integer
Byte
Byte
Byte

SByte
SByte
sbyte

Int16
Short
short

Int32
integer
int

Int64
Long
Long

UInt16
UShort
ushort

UInt32
UInteger
uint

UInt64
ULong
ulong
Floating point
Single
Single
float

Double
Double
double
Logical
Boolean
Boolean
bool
Other
Char
Char
char

Decimal
Decimal
decimal

Intptr
IntPtr
No built-in-type
IntPtr
No built-in-type

UIntptr
UIntPtr
No built-in-type
UIntPtr
No built-in-type
Class object
Object
Object
object

String
String
string


Table for Data types their Memory Sizes and Ranges

       Type
              Range
           Size
sbyte
-128 to 127
Signed 8-bit integer
byte
0 to 255
Unsigned 8-bit integer
char
U+0000 to U+ ffff
Unicode 16-bit character
short
-32,768 to 32767
Signed 16-bit integer
ushort
0 to 65,535
Unsigned 16-bit integer
int
-2,147,483,648 to 2,147,483,647
Signed 32-bit integer
uint
0 to 4,294,967,295
Unsigned 32-bit integer
long
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Signed 64-bit integer
ulong
0 to 18,446,744,073,709,551,615
Unsigned 64-bit integer
Floating point
1.5*10-45 to 3.4 *1038, 7-digit precision
Signed 32-bit integer
double
5.0*10-324 to 1.7*10308, 15-digit precision
Signed 32-bit integer
decimal
1.0*10-28 to 7.9 *1028, 28-digit precision
Signed 128-bit integer
 

Key words in C#.NET

Keywords are predefined reserved identifiers that have special meaning to the compiler
Keyword cannot be used as variables in your program unless they include @ as a prefix
C#.Net supports 2 types of keywords 1) Reserved keywords 2) Contextual keywords
There are 77 Reserved keywords and 6 Contextual keywords present in C#.Net

Reserved keywords

abstract                     event                   new                  struct
as                              explicit                null                  switch
base                          extern                  object               this
bool                          false                     operator           throw
break                        finally                  out                    true
byte                          fixed                     override           try
case                          float                      params             typeof
catch                         for                        private              uint
char                           foreach                protected           ulong
checked                     goto                     public                unchecked
class                          if                          readonly             unsafe
const                         implicit                ref                       ushort
continue                    in                         return                  using
decimal                     int                        sbyte                   virtual
default                      interface               sealed                  volatile
delegate                    internal                 short                    void
do                             is                         sizeof                  while
double                      lock                      stacklloc
else                           long                      static
enum                        namespace            string

Contextual keywords

get               partial                 set
value           where                 yield

  • A Contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#
  • get Defines an accessor method for a property or an indexer
  • partial Defines partial classes, structs, and interfaces throughout the same compilation unit
  • set Defines an accessor method for a property or an indexer
  • where Adds constraints to a generic declaration
  • yield Used in an iterator block to return a value to the enumerator object or to signal the end of iteration
  • value Used to set accessors and to add or remove event handlers.



No comments:

Post a Comment