using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ConsoleApplication2
{
class Program
{
public class Test
{
int t1;
public int T1
{
get { return t1; }
set { t1 = value; }
}
int t2;
public int T2
{
get {
if (t2 < 3)
{
return 0;
}
else
{
return t2;
}
}
set { t2 = value; }
}
}
/// <summary>
/// 本文档主要做封装继承多态的解释
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Test t = new Test();
t.T1 = 1;
t.T2 = 2;
foreach (System.Reflection.PropertyInfo p in t.GetType().GetProperties())
{
Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(t,null));
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ConsoleApplication2
{
class Program
{
public class Test
{
int t1;
public int T1
{
get { return t1; }
set { t1 = value; }
}
int t2;
public int T2
{
get {
if (t2 < 3)
{
return 0;
}
else
{
return t2;
}
}
set { t2 = value; }
}
}
/// <summary>
/// 本文档主要做封装继承多态的解释
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Test t = new Test();
t.T1 = 1;
t.T2 = 2;
foreach (System.Reflection.PropertyInfo p in t.GetType().GetProperties())
{
Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(t,null));
}
Console.ReadKey();
}
}
}