<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FReflection%2FProperty</id>
		<title>Csharp/CSharp Tutorial/Reflection/Property - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FReflection%2FProperty"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Reflection/Property&amp;action=history"/>
		<updated>2026-04-30T02:21:14Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Reflection/Property&amp;diff=5956&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Reflection/Property&amp;diff=5956&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Reflection/Property&amp;diff=5957&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Reflection/Property&amp;diff=5957&amp;oldid=prev"/>
				<updated>2010-05-26T12:17:50Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Get/set a property using a PropertyInfo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Windows.Forms; &lt;br /&gt;
  public class Class1&lt;br /&gt;
  {&lt;br /&gt;
      static void Main( string[] args )&lt;br /&gt;
      {&lt;br /&gt;
        Type type = typeof(MyClass);&lt;br /&gt;
        object o = Activator.CreateInstance(type);&lt;br /&gt;
        &lt;br /&gt;
             //get and set a property using a PropertyInfo&lt;br /&gt;
         PropertyInfo property = type.GetProperty(&amp;quot;Text&amp;quot;);&lt;br /&gt;
         property.SetValue(o, &amp;quot;www.softconcepts.ru&amp;quot;, null);&lt;br /&gt;
         string text = (string)property.GetValue(o, null);&lt;br /&gt;
        &lt;br /&gt;
         Console.WriteLine(text);&lt;br /&gt;
        &lt;br /&gt;
         EventInfo eventInfo = type.GetEvent(&amp;quot;Changed&amp;quot;);&lt;br /&gt;
         eventInfo.AddEventHandler(o, new EventHandler(Class1.OnChanged));&lt;br /&gt;
             ((MyClass)o).Text = &amp;quot;New Value&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      private static void OnChanged(object sender , System.EventArgs e)&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(((MyClass)sender).Text);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  public class MyClass&lt;br /&gt;
  {&lt;br /&gt;
    private string text;&lt;br /&gt;
    &lt;br /&gt;
    public string Text&lt;br /&gt;
    {&lt;br /&gt;
      get{ return text; }&lt;br /&gt;
      set&lt;br /&gt;
      { &lt;br /&gt;
        text = value;&lt;br /&gt;
        OnChanged(); &lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private void OnChanged()&lt;br /&gt;
    {&lt;br /&gt;
      if( Changed != null )&lt;br /&gt;
        Changed(this, System.EventArgs.Empty); &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public event EventHandler Changed;&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==List Properties==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
public interface IFaceOne&lt;br /&gt;
{&lt;br /&gt;
  void MethodA();&lt;br /&gt;
}&lt;br /&gt;
public interface IFaceTwo&lt;br /&gt;
{&lt;br /&gt;
  void MethodB();&lt;br /&gt;
}&lt;br /&gt;
public class MyClass: IFaceOne, IFaceTwo&lt;br /&gt;
{&lt;br /&gt;
  public enum MyNestedEnum{}&lt;br /&gt;
  &lt;br /&gt;
  public int myIntField;&lt;br /&gt;
  public string myStringField;&lt;br /&gt;
  public void myMethod(int p1, string p2)&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
  public int MyProp&lt;br /&gt;
  {&lt;br /&gt;
    get { return myIntField; }&lt;br /&gt;
    set { myIntField = value; }&lt;br /&gt;
  }&lt;br /&gt;
  void IFaceOne.MethodA(){}&lt;br /&gt;
  void IFaceTwo.MethodB(){}&lt;br /&gt;
}&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyClass f = new MyClass();&lt;br /&gt;
       Type t = f.GetType();&lt;br /&gt;
    PropertyInfo[] pi = t.GetProperties();&lt;br /&gt;
    foreach(PropertyInfo prop in pi)&lt;br /&gt;
      Console.WriteLine(&amp;quot;Prop: {0}&amp;quot;,  prop.Name);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Prop: MyProp&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using Type.GetProperties() to Obtain an Object&amp;quot;s Public Properties==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    DateTime dateTime = new DateTime();&lt;br /&gt;
    &lt;br /&gt;
    Type type = dateTime.GetType();&lt;br /&gt;
    foreach (&lt;br /&gt;
        System.Reflection.PropertyInfo property in&lt;br /&gt;
            type.GetProperties())&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(property.Name);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>