1个回答
展开全部
public class Program
{
private static void Main(string[] args)
{
Person person = new Person();
person.Name = "吕小布";
person.Height = 183;
person.Sex = "男";
person.Weight = 60;
person.Hobit = "篮球";
Console.WriteLine("姓名: {0},身高: {1},性别: {2},体重: {3},爱好: {4}",person.Name,person.Height,person.Sex,person.Weight,person.Hobit);
Console.Read();
}
public class Person
{
public string Name { get; set; }
public string Sex { get; set; }
public int Height { get; set; }
public int Weight { get; set; }
public string Hobit { get; set; }
public Person()
{
}
}
}
追问
可以设置成单独一行的吗
就是像这样
姓名:XXX
年龄:XXX
……
这种格式
追答
public class Program
{
private static void Main(string[] args)
{
Person person = new Person();
person.Name = "吕小布";
person.Height = 183;
person.Sex = "男";
person.Weight = 60;
person.Hobit = "篮球";
Console.WriteLine("姓名: {0}",person.Name);
Console.WriteLine("性别: {0}", person.Sex);
Console.WriteLine("身高: {0}", person.Height);
Console.WriteLine("体重: {0}", person.Weight);
Console.WriteLine("爱好: {0}", person.Hobit);
Console.ReadLine();
}
public class Person
{
public string Name { get; set; }
public string Sex { get; set; }
public int Height { get; set; }
public int Weight { get; set; }
public string Hobit { get; set; }
public Person()
{
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询