Mega Code Archive
Searches for the public property with the specified name and return type
using System;
using System.Reflection;
class MyClass1
{
String myMessage = "Hello World.";
public string MyProperty1
{
get
{
return myMessage;
}
set
{
myMessage = value;
}
}
}
class TestClass
{
static void Main()
{
Type myType = typeof(MyClass1);
PropertyInfo myStringProperties1 = myType.GetProperty("MyProperty1", typeof(string));
Console.WriteLine("The name of the first property of MyClass1 is {0}.", myStringProperties1.Name);
Console.WriteLine("The type of the first property of MyClass1 is {0}.", myStringProperties1.PropertyType);
}
}