using System;
using System.Collections.Generic;
using System.Text;namespace aaa
{
    class UserIntType
    {
        private string _display;
        private int _val;        public UserIntType(string display, int val)
        {
            this._display = display;
            this._val = val;
        }        public string DisplayName
        {
            get { return this._display; }
        }        public int ValueName
        {
            get { return this._val; }
        }
    }
}
最好能给出注释,这个类是来做什么的,配和api使用

解决方案 »

  1.   

    using System; 
    using System.Collections.Generic; 
    using System.Text; namespace aaa 

        public class UserIntType  //加上public 不然不是内部类 无法访问。
        { 
            private string _display;  //没什么好说,就定义了2个属性,一个DisplayName ,一个ValueName 怎两个属性只能访问,不能赋值
            private int _val;         public UserIntType(string display, int val) 
            { 
                this._display = display; 
                this._val = val; 
            }         public string DisplayName 
            { 
                get { return this._display; } 
            }         public int ValueName 
            { 
                get { return this._val; } 
            } 
        } 
      

  2.   

    using System; 
    using System.Collections.Generic; 
    using System.Text; namespace aaa 

        class UserIntType 
        { 
            private string _display; 
            private int _val;         public UserIntType(string display, int val) 
            { 
                this._display = display;  赋值
                this._val = val; 赋值
            }         //获取_display值
            public string DisplayName 
            { 
                get { return this._display; } 
            }         //获取_val值
            public int ValueName 
            { 
                get { return this._val; } 
            } 
        } 
      

  3.   

    using System; 
    using System.Collections.Generic; 
    using System.Text; namespace aaa 

        class UserIntType 
        { 
            private string _display; 
            private int _val; 
            
    //构造函数初始化内部的私有变量
            public UserIntType(string display, int val) 
            { 
                this._display = display;  赋值 
                this._val = val; 赋值 
            }         //使用公有的属性返回 私有的字段数据,外界只能访问DisplayName,不能修改(应为没有给set块)
            public string DisplayName 
            { 
                get { return this._display; } 
            }         //同上
            public int ValueName 
            { 
                get { return this._val; } 
            } 
        }