C# TypeInfo GetMember(String, BindingFlags)
Description
TypeInfo GetMember(String, BindingFlags)
Searches
for the specified members, using the specified binding constraints.
Syntax
TypeInfo.GetMember(String, BindingFlags)
has the following syntax.
public virtual MemberInfo[] GetMember(
string name,
BindingFlags bindingAttr
)
Parameters
TypeInfo.GetMember(String, BindingFlags)
has the following parameters.
name
- The string containing the name of the members to get.bindingAttr
- A bitmask comprised of one or more BindingFlags that specify how the search is conducted.bindingAttr
- -or-bindingAttr
- Zero, to return an empty array.
Returns
TypeInfo.GetMember(String, BindingFlags)
method returns
Example
using System;/* ww w. ja va 2 s . c om*/
using System.Security;
using System.Reflection;
public class MyMemberSample
{
public static void Main()
{
String myString = "GetMember_String_BindingFlag";
Type myType = myString.GetType();
MemberInfo[] myMembers = myType.GetMember("C*",
BindingFlags.Public |BindingFlags.Static);
if(myMembers.Length > 0)
{
Console.WriteLine("\nThe public static member(s) starting with the letter C for type {0}:", myType);
for(int index=0; index < myMembers.Length; index++)
Console.WriteLine("Member {0}: {1}", index + 1, myMembers[index].ToString());
}
}
}
The code above generates the following result.