Get Type Code after casting : Data Type Cast « Data Type « C# / CSharp Tutorial






using System;

using System.Globalization;

class MainClass
{
  static void Main(string[] args)
  {      
    // Get the type code of C# int.
    int theInt = 65;
    Console.WriteLine("Type code of int is: {0}", theInt.GetTypeCode());

    Console.WriteLine("Casting System.Int32 to System.Char");
    char theChar = (char)theInt;  
    Console.WriteLine("Type code int converted to char is: {0}", theChar.GetTypeCode());
    Console.WriteLine("Value of converted char: {0}", theChar);
    
  }
}
Type code of int is: Int32
Casting System.Int32 to System.Char
Type code int converted to char is: Char
Value of converted char: A








2.50.Data Type Cast
2.50.1.Type Conversion in Expressions
2.50.2.Automatic Conversions
2.50.3.The use of the cast operator: how information loss can occur when explicitly converting a variable of one type to another
2.50.4.Automatic conversion from long to double
2.50.5.Cast an int into a double
2.50.6.Cast an int into a byte, no data lost
2.50.7.Cast an int into a byte, data lost
2.50.8.Cast a uint into a short, no data lost
2.50.9.Cast a uint into a short, data lost
2.50.10.Cast a long into a uint, no data lost
2.50.11.cast a long into a uint, data lost
2.50.12.Cast an int into a char
2.50.13.Cast byte back for byte calculation
2.50.14.Using casts in an expression.
2.50.15.Conversions of numeric types: checked and unchecked conversions
2.50.16.Conversions of numeric types: checked conversions block
2.50.17.Using checked and unchecked.
2.50.18.Using checked and unchecked with statement blocks.
2.50.19.Most significant bits lost
2.50.20.Raises the OverflowException exception
2.50.21.Get Type Code after casting
2.50.22.Narrow With Convert
2.50.23.Narrowing int to byte
2.50.24.Overflow Check for data type converting
2.50.25.Not Using the Cast Operator for an Implicit Cast
2.50.26.Using the Cast Operator for an Implicit Cast
2.50.27.Data Conversion
2.50.28.implicit type conversions supported in C#.