在這個代碼片斷中
Code
Listing
using System;
namespace CompilerGeneratedProps
{
public class Employee : Person
{
//Fields
protected string Title;
}
}
Listing
using System;
namespace CompilerGeneratedProps
{
public class Person
{
//Fields
protected string _LastName; //Declared protected for extensibility
//Properties
public string FirstName { get; set; } //Auto
public string LastName
{
get
{
return this
}
set
{
this
}
}
}
}
Listing
using System;
using System
namespace CompilerGeneratedProps
{
public class Program
{
static void Main(string[] args)
{
Console
Console
Person objPerson = new Person();
foreach (FieldInfo fi in
objPerson
BindingFlags
{
Console
}
Console
Console
Employee objEmployee = new Employee();
foreach (FieldInfo fi in
objEmployee
BindingFlags
{
Console
}
Console
}
}
}
結果輸出
項目下載
結論
如果在一個父類中使用自動實現屬性
From:http://tw.wingwit.com/Article/program/net/201311/13584.html