日期:2014-05-17  浏览次数:20703 次

这是啥语法
这咋用,干啥用的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace Csharp
{
    class People
    {
        private int myInt;
        public int MyIntProp//这是什么玩意
        {
            get
            {
                return myInt;
            }
            set
            {
                myInt = value;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            People p = new People();
            p.MyIntProp = 1;
            Console.ReadKey();
        }

    }
}

------解决方案--------------------
这个是属性啊。
------解决方案--------------------
MyIntProp是My(我的)Integer(整数)Property(属性)的意思。
------解决方案--------------------
目测楼主是学C++的...我也不懂这是啥意思
------解决方案--------------------
这个是属性语法啊,如果是.NET FrameWork 3.0以上的话,可以简写成

private int myInt;
public int MyIntProp
{
    get
    {
         return myInt;
    }
    set
    {
        myInt = value;
    }
}

========》简写成

public int MyIntProp { get;set; }
------解决方案--------------------
        private int myInt;
        public int MyIntProp
        {
            get
            {
                return myInt;
            }
            set
            {