日期:2014-05-18  浏览次数:20861 次

急求解
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;
  }