C# | Byte.GetTypeCode() Method
Last Updated :
11 Aug, 2021
This method is used to return the TypeCode for value type Byte.
Syntax:
public TypeCode GetTypeCode ();
Return Value: It returns the enumerated constant, Byte.
Below programs illustrate the use of Byte.GetTypeCode() Method:
Example 1:
CSharp
using System;
class GFG {
public static void Main()
{
byte val1;
bool val2;
val1 = 12;
val2 = true ;
TypeCode t1 = val1.GetTypeCode();
TypeCode t2 = val2.GetTypeCode();
Console.WriteLine( "TypeCode of val1 is {0}" , t1);
Console.WriteLine( "TypeCode of val2 is {0}" , t2);
}
}
|
Output:
TypeCode of val1 is Byte
TypeCode of val2 is Boolean
Example 2:
csharp
using System;
class GFG {
public static void Main()
{
byte val1;
bool val2;
val1 = 12;
val2 = true ;
get (val1);
get (val2);
}
public static void get ( byte val)
{
TypeCode t = val.GetTypeCode();
Console.WriteLine( "TypeCode of {0} is {1}" , val, t);
}
public static void get ( bool val)
{
TypeCode t = val.GetTypeCode();
Console.WriteLine( "TypeCode of {0} is {1}" , val, t);
}
}
|
Output:
TypeCode of 12 is Byte
TypeCode of True is Boolean
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...