C# में Int16.GetTypeCode() विधि का उपयोग Int16 के मान प्रकार के लिए TypeCode को वापस करने के लिए किया जाता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public TypeCode GetTypeCode ();
उदाहरण
आइए अब Int16.GetTypeCode() पद्धति को लागू करने के लिए एक उदाहरण देखें -
using System; public class Demo { public static void Main(){ short val1 = 0; short val2 = Int16.MaxValue; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("HashCode for value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for value2 = "+val2.GetHashCode()); Console.WriteLine("Are they equal? = "+(val1.Equals(val2))); TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("TypeCode for val1 = "+type1); Console.WriteLine("TypeCode for val2 = "+type2); } }
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
Value1 = 0 Value2 = 32767 HashCode for value1 = 0 HashCode for value2 = 2147450879 Are they equal? = False TypeCode for val1 = Int16 TypeCode for val2 = Int16
उदाहरण
आइए अब Int16.GetTypeCode() पद्धति को लागू करने के लिए एक और उदाहरण देखें -
using System; public class Demo { public static void Main(){ short val1 = 23; short val2 = 0; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("HashCode for value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for value2 = "+val2.GetHashCode()); Console.WriteLine("Are they equal? = "+(val1.Equals(val2))); TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("TypeCode for val1 = "+type1); Console.WriteLine("TypeCode for val2 = "+type2); } }
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
Value1 = 23 Value2 = 0 HashCode for value1 = 1507351 HashCode for value2 = 0 Are they equal? = False TypeCode for val1 = Int16 TypeCode for val2 = Int16