C#-এ Type.GetTypeFromHandle() মেথডটি নির্দিষ্ট টাইপ হ্যান্ডেল দ্বারা রেফারেন্সড টাইপ পেতে ব্যবহৃত হয়।
সিনট্যাক্স
public static Type GetTypeFromHandle (RuntimeTypeHandle handle);
উপরে, handle প্যারামিটার হলো টাইপকে রেফার করার অবজেক্ট।
উদাহরণ
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(short);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
}
আউটপুট
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit
আরেকটি উদাহরণ
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(System.Type);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
}
আউটপুট
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit