C# TypeInfo GetMember(String)
Description
TypeInfo GetMember(String)
Searches for the public
members with the specified name.
Syntax
TypeInfo.GetMember(String)
has the following syntax.
public MemberInfo[] GetMember(
string name
)
Parameters
TypeInfo.GetMember(String)
has the following parameters.
name
- The string containing the name of the public members to get.
Returns
TypeInfo.GetMember(String)
method returns
Example
using System;//from w w w.j av a2 s .c o m
using System.Security;
using System.Reflection;
public class MyMemberSample
{
public static void Main()
{
String myString = "GetMember_String";
Type myType = myString.GetType();
MemberInfo[] myMembers = myType.GetMember("C*");
if(myMembers.Length > 0)
{
Console.WriteLine("\nThe 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());
}
else
Console.WriteLine("No members match the search criteria.");
}
}
The code above generates the following result.