Boolean.GetTypeCode Method in C# with Examples
Boolean.GetTypeCode method is used to get the TypeCode for value type Boolean.
Syntax: public TypeCode GetTypeCode ();
Return Value: This method returns the enumerated constant Boolean.
Below programs illustrate the use of the above discussed-method:
Example 1:
using System;
class GFG {
public static void Main()
{
bool s1 = true ;
TypeCode result = s1.GetTypeCode();
Console.WriteLine( "TypeCode for {0} is: {1}" ,
s1, result);
}
}
|
Output:
TypeCode for True is: Boolean
Example 2:
using System;
class GFG {
public static void Main()
{
result( true );
result( false );
}
public static void result( bool val)
{
TypeCode code = val.GetTypeCode();
Console.WriteLine( "TypeCode for {0} is {1}" ,
val, code);
}
}
|
Output:
TypeCode for True is Boolean
TypeCode for False is Boolean
Reference:
Last Updated :
23 Apr, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...