Skip to content
Related Articles

Related Articles

C# | Byte.GetTypeCode() Method
  • Last Updated : 11 Feb, 2019

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:






// C# program to demonstrate
// Byte.GetTypeCode() Method
using System;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // Declaring val1 and val2
        byte val1;
        bool val2;
  
        // intializing the
        // val1 and val2
        val1 = 12;
        val2 = true;
  
        // getting TypeCode
        // using GetTypeCode() method
        TypeCode t1 = val1.GetTypeCode();
        TypeCode t2 = val2.GetTypeCode();
  
        // Display TypeCode
        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:




// C# program to demonstrate
// Byte.GetTypeCode() Method
using System;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // Declaring val1 and val2
        byte val1;
        bool val2;
  
        // intializing the
        // val1 and val2
        val1 = 12;
        val2 = true;
  
        // calling get() method
        get(val1);
        get(val2);
    }
  
    // Defining the get() method
    public static void get(byte val)
    {
  
        // getting TypeCode
        // using GetTypeCode() method
        TypeCode t = val.GetTypeCode();
  
        // Display the TypeCode
        Console.WriteLine("TypeCode of {0} is {1}", val, t);
    }
  
    public static void get(bool val)
    {
  
        // getting TypeCode
        // using GetTypeCode() method
        TypeCode t = val.GetTypeCode();
  
        // Display the TypeCode
        Console.WriteLine("TypeCode of {0} is {1}", val, t);
    }
}
Output:
TypeCode of 12 is Byte
TypeCode of True is Boolean

Reference:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :