为类扩展方法获取该类的所有属性值

View Code
 1 using System;
 2 public class GetValue
 3 {
 4     /*为People扩展一个方法ToValue
 5    要求为:能把People里面所有属性的值打印出来*/
 6     public static void Main()
 7     {
 8         People people = new People();
 9         people.Get("康熙",300);
10     }
11 }
12 public static class ToValue
13 {
14     public static void Get(this People peo,string Name,int Age)
15     {
16         Console.WriteLine(Name + Age );
17     }
18 }
19 public class People
20 {
21         
22 }

 

你可能感兴趣的:(方法)