Type Casting is a concept of converting one data type into another data type.C# supports two types of type casting. They are..
- Implicit Type Casting
- Explicit Type Casting
C # supports three types of explicit type castings: They are
- C++ style of type casting
- Eg.,: int i = 100;
byte b = (byte) i;
- Parsing: Parse () is used to convert string data type into any data type.
E.g.: int i = int.Parse (txtName.Text);
- Converting: Convert is used to convert any data type into any required data type.
E.g.: Convert.ToInt32();
Methods of Convert class:
- Convert.ToChar()
- Convert.ToByte()
- Convert.ToFloat()
- Convert.ToINT16() //for Short Int
- Convert.ToINT32() //for int
- Convert.ToINT64() //for long
0 comments :
Post a Comment