读书人

急求解,该如何解决

发布时间: 2012-03-27 13:44:24 作者: rapoo

急求解
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1;

namespace ConsoleApplication1
{

class ReadProperty
{
private string name;
ReadProperty(string name)
{
this.name = name;
}
public string Name
{
get
{
return this.name;
}
}
}
class PropertyTest
{
private int age;
PropertyTest(int age)
{
this.age = age;
}
public int Age
{
get
{
return this.age;
}
set
{
if (value > 0 && value <= 100)
{
this.age = value;
}
}
}
}

class Test
{
static void Main(string[] args)
{
PropertyTest propertyTest = new PropertyTest(25);
propertyTest.Age = 33;
Console.WriteLine("年龄为:{0}",propertyTest.Age);
ReadProperty readProperty=new ReadProperty("张三丰");
Console.WriteLine("姓名为:", readProperty.Name);
Console.Read();

}
}
}
为什么编译不过呢, 提示参数错误[b][/b]

[解决办法]

C# code
//构造函数加上public 修饰  public ReadProperty(string name)  {  this.name = name;  } 

读书人网 >C#

热点推荐