কম্পিউটার

C# এ Type.GetProperties() পদ্ধতি


C# এ Type.GetProperties() পদ্ধতিটি বর্তমান প্রকারের বৈশিষ্ট্যগুলি পেতে ব্যবহৃত হয়।

সিনট্যাক্স

নিচের সিনট্যাক্স −

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
System.Reflection.MethodBase DeclaringMethod
System.Type ReflectedType
System.Runtime.InteropServices.StructLayoutAttribute StructLayoutAttribute
System.Guid GUID
System.Reflection.Binder DefaultBinder
System.Reflection.Module Module
System.Reflection.Assembly Assembly
System.RuntimeTypeHandle TypeHandle
System.String FullName
System.String Namespace
System.String AssemblyQualifiedName
System.Type BaseType
System.Reflection.ConstructorInfo TypeInitializer
Boolean IsNested
System.Reflection.TypeAttributes Attributes
System.Reflection.GenericParameterAttributes GenericParameterAttributes
Boolean IsVisible
Boolean IsNotPublic
Boolean IsPublic
Boolean IsNestedPublic
Boolean IsNestedPrivate
Boolean IsNestedFamily
Boolean IsNestedAssembly
Boolean IsNestedFamANDAssem
Boolean IsNestedFamORAssem
Boolean IsAutoLayout
Boolean IsLayoutSequential
Boolean IsExplicitLayout
Boolean IsClass
Boolean IsInterface
Boolean IsValueType
Boolean IsAbstract
Boolean IsSealed
Boolean IsEnum
Boolean IsSpecialName
Boolean IsImport
Boolean IsSerializable
Boolean IsAnsiClass
Boolean IsUnicodeClass
Boolean IsAutoClass
Boolean IsArray
Boolean IsGenericType
Boolean IsGenericTypeDefinition
Boolean IsConstructedGenericType
Boolean IsGenericParameter
Int32 GenericParameterPosition
Boolean ContainsGenericParameters
Boolean IsByRef
Boolean IsPointer
Boolean IsPrimitive
Boolean IsCOMObject
Boolean HasElementType
Boolean IsContextful
Boolean IsMarshalByRef
System.Type[] GenericTypeArguments
Boolean IsSecurityCritical
Boolean IsSecuritySafeCritical
Boolean IsSecurityTransparent
System.Type UnderlyingSystemType
System.String Name
System.Collections.Generic.IEnumerable`1[System.Reflection.CustomAttributeData] CustomAttributes
Int32 MetadataToken

উদাহরণ

Type.GetProperties() পদ্ধতি -

বাস্তবায়নের জন্য এখন আরেকটি উদাহরণ দেখা যাক
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

  1. C# এ Type.GetTypeFromHandle() পদ্ধতি

  2. C# এ Type.GetArrayRank() পদ্ধতি

  3. C# এ Type.Equals() পদ্ধতি

  4. C# এ ElementAt() পদ্ধতি