সিনট্যাক্স
public System.Reflection.PropertyInfo[] GetProperties (); public abstract System.Reflection.PropertyInfo[] GetProperties (System.Reflection.BindingFlags bindingAttr);
উপরোক্তে, bindingAttr হলো এনিউমারেশন মানগুলির বিটওয়াইজ কম্বিনেশন যা নির্দেশ করে সার্চ কীভাবে করা হবে।
উদাহরণ
using System;
using System.Reflection;
public class Demo {
public static void Main(){
Type type = typeof(System.Type);
PropertyInfo[] info = type.GetProperties();
Console.WriteLine("Properties... ");
for (int i = 0; i < info.Length; i++)
Console.WriteLine(" {0}", info[i].ToString());
}
}
আউটপুট
Properties... System.Reflection.MemberTypes MemberType System.Type DeclaringType ... (বিস্তারিত প্রপার্টি তালিকা)
আরেকটি উদাহরণ
using System;
using System.Reflection;
public class Demo {
public static void Main(){
Type type = typeof(string);
PropertyInfo[] info = type.GetProperties();
Console.WriteLine("Count of Properties = " + info.Length);
Console.WriteLine("Properties... ");
for (int i = 0; i < info.Length; i++)
Console.WriteLine(" {0}", info[i].ToString());
}
}
আউটপুট
Count of Properties = 2 Properties... Char Chars [Int32] Int32 Length