Mega Code Archive

 
Categories / C# Tutorial / Reflection
 

Type identity

Runtime type ID is the mechanism that lets you identify a type during the execution of a program. Reflection enables you to obtain information about a type. using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text; public class MainClass {     public static void Main()     {         string s = "A string";         Type t = s.GetType();         Console.WriteLine(t.Name);                       Console.WriteLine(t.Namespace);                  Console.WriteLine(t.IsPublic);                   Console.WriteLine(t == typeof(string));      } } String System True