SByte.GetTypeCode Method in C# with Examples
SByte.GetTypeCode method is used to get the TypeCode for value type SByte.
Syntax: public TypeCode GetTypeCode ();
Return Value: This method returns the enumerated constant SByte.
Below programs illustrate the use of the above discussed-method:
Example 1:
// C# program to illustrate the // SByte.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // Taking sbyte value sbyte s1 = 56; // Getting the typecode for SByte // using GetTypeCode() method TypeCode result = s1.GetTypeCode(); // Display the TypeCode Console.WriteLine( "TypeCode for SByte is: {0}" , result); } } |
Output:
TypeCode for SByte is: SByte
Example 2:
// C# program to illustrate the // SByte.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // using result() Method result(SByte.MinValue); result(SByte.MaxValue); } // result() method public static void result( sbyte val) { // using GetTypeCode() method TypeCode code = val.GetTypeCode(); // Display the TypeCode Console.WriteLine( "TypeCode for {0} is {1}" , val, code); } } |
Output:
TypeCode for -128 is SByte TypeCode for 127 is SByte
Reference:
- https://docs.microsoft.com/en-us/dotnet/api/system.sbyte.gettypecode?view=netcore-2.1