C# Type GUID

Description

Type GUID gets the GUID associated with the Type.

Syntax

Type.GUID has the following syntax.


public abstract Guid GUID { get; }

Example

The following example creates the class MyClass1 with a public method, creates a Type object corresponding to MyClass1, and gets the Guid structure using the GUID property of the Type class.


/*from   ww w. j av a  2  s  . c om*/
using System;

public class MyClass1
{
   public void MyMethod1()
   {
   }
}
    
class MyGetTypeFromCLSID
{

    public static void Main()
    {
        Type myType = typeof(MyClass1);
        Guid myGuid =(Guid) myType.GUID;
        Console.WriteLine(myType.ToString());
        Console.WriteLine(myType.GUID);        
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version