c#编译问题:代码无误,为何不达效果? using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication3 { class Person { private String name = "张三"; private int age = 12; public void Display() { Console.WriteLine("姓名:{0},年龄:{1}",name,age); } public void setName(string personName)
{ name = personName; }
public void setAge(int personAge) { age = personAge; } public Person(string Name, int Age) { name=Name;age=Age; } public Person() { name = "田七"; age = 70; } } class Class1
{ static void Main(string[] args) { Person oneperson = new Person("李四",30); oneperson.Display(); oneperson.setName("王五"); oneperson.setAge(40); oneperson.Display(); oneperson = new Person(); oneperson.Display();
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Person
{
private String name = "张三";
private int age = 12;
public void Display()
{ Console.WriteLine("姓名[color=#800000]:{0},[/color]年龄[color=#800000]:{1}",[/color]this.name,this.age); }
public void setName(string personName)
{ name = personName; }
public void setAge(int personAge)
{ age = personAge; }
public Person(string Name, int Age)
{ name = Name; age = Age; }
public Person()
{ name = "田七"; age = 70; }
}
class Program
{
static void Main(string[] args)
{
Person oneperson = new Person("李四", 30);
oneperson.Display();
oneperson.setName("王五");
oneperson.setAge(40);
oneperson.Display();
oneperson = new Person();
oneperson.Display();
Console.ReadKey();
}
}
}
这里的括号问题
------解决方案--------------------