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

定义属性的有关问题

2012-01-12 
定义属性的问题using Systemusing System.Collections.Genericusing System.Textnamespace ConsoleAppl

定义属性的问题
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
  class Program
  {
  static void Main(string[] args)
  {
  }
   
  }
  class recaver
  {
  private double x, y, z;
  public double x
  {
  get { return x; }
  set { x = value; }
  }
  }
}

这样定义X属性不对吗???编译不过去啊,哪位大师帮解决下

[解决办法]
属性名和私有变量名重名了

C# code
    class recaver    {        private double _x, y, z;        public double x        {            get { return _x; }            set { _x = value; }        }    } 

热点排行