public int Wint(int DataInt){
        get{
            return 0;
        }
        set {
    DataInt = value;
    }
    }我希望的就是可以用
Wint(AA) = 123;
使用的是set{};将设置AA值为value
或者int AA = Wint(AA);
使用的是get{};返回一个值.

解决方案 »

  1.   

    Short answer is "No".
    Indexer不一定符合你的要求。
    只好用函数了。
      

  2.   

    Wint(AA)   =   123; 这种方式是 vb 中的
    c#中应该是Wint[AA]   =   123; 这样可以使用 索引器
      

  3.   

    我晕 索引器……
    数组(我的认法……)
    索引器可以发送中文么,记得索引器只能是数字,且整型。
    我以前用VB在class里写的时候是这样写的:'获取文件内容
    Dim Test : Test = Fun.Doc("Test.txt")'书写文件内容
    Fun.Doc("Test.txt") = "内容内容内容内容"
    这样写和这样读,很爽,很舒服,很痛快。所以想看看C#中是不是也有这样的写法。
      

  4.   

    用索引器啊,
    Test test=Fun.Doc["Test.txt"];
    Fun.Doc["Test.txt"]="内容内容内容内容";DataRow["ColumnName"]就是用索引器的例子
    索引器的参数可以是任意类型,但是一般建议用int或string作为参数
      

  5.   

    补充Fun.Doc是返回某个带索引器的类的实例
      

  6.   

    public class Test {
    public System.Int32[] HanTest = new System.Int32[256];
    public int this[int index] {
    get {
    return HanTest[index];
    }
    set {
    HanTest[index] = value;
    }
    }
    }
    //使用
    Test HanTest = new Test();
    HanTest[1] = 10;
    Response.Write(HanTest[1]);
    每次都要一个Test HanTest = new Test();还是不爽。
      

  7.   

    LS的很透彻,这个问题在C#中显然应该使用函数而不是属性来解决。
      

  8.   

    使用索引,实现通过this关键字。