首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

急求解,该如何解决

2012-03-27 
急求解using Systemusing System.Collections.Genericusing System.Linqusing System.Textusing Conso

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

热点排行