01.重写ToString()
using System
;
using static System
.Console
;
namespace Array
{
class Program
{
static void Main(string[] args
)
{
People people
=new People(5,"一休");
WriteLine(people
.ToString());
ReadKey();
}
}
class People
{
public int Age
{ get; set; }
public string Name
{ get; set; }
public People(int age
, string name
)
{
this.Age
= age
;
this.Name
= name
;
}
public override string ToString()
{
return $
"名字:{Name},年龄:{Age}";
}
}
}
转载请注明原文地址: https://mac.8miu.com/read-485776.html