首先,您应该重构您的代码以用 Person 替换 Age :
public class Person
{
public string Name { get; set; }
public string Age { get; set; }
}
然后,在你的程序中,你需要一个存放你的人的地方和一个显示结果的方法:
class Program
{
public static Person Person { get; set; }
static void Main(string[] args)
{
Person = new Person
{
Age = 10,
Name = "Andrew"
};
TestOutput();
}
/// <summary>
/// Method to show result
/// </summary>
static void TestOutput()
{
Console.WriteLine(Person.Name);
}
}
守着星空守着你
相关分类