我想在一个窗体里面设置一个属性,在别的窗体给它赋值,为什么我取不到赋值??public string abc;public this[int i]
{
get{return abc[i]}set{abc[i]=value}
}

解决方案 »

  1.   

    在子窗体中
    form fm=new form();
    fm.abc[i]=......在子窗体我取到值了,我用textbox试了一下主窗体中this.textbox.text=abc[0]可是取不到值
      

  2.   

    上面定义的是public string abc;到后面调用怎么就abc[i]了,这数据类型能对上么。
      

  3.   

    如果abc是你主窗体中的变量,应该没问题,abc有内容吗
      

  4.   

    当然,不发表意见 斑竹就是 对我下手了:public this[int i]
    {
    get{return abc[i]}
    set{abc[i]=value}
    }这个代码应该是一个 错误代码,编译不通过,应该改成:public char this[int i]    //string 类型的 单个数据 就是 char
    {
    get{return abc[i]}
    set{abc[i]=value}
    }
      

  5.   

    string的索引访问是只读的,不可以写
    set{abc[i]=value}我是说你这个写操作是不成功的
      

  6.   

     private static void TextCollection(Dictionary<string, int> cntListV)
            {
                var cntListVLinq = from p in cntListV
                                   orderby p.Key
                                   select p;
                cntListV = cntListVLinq.ToDictionary(cnt => cnt.Key, cnt => cnt.Value);
                foreach (var item in cntListV)
                {
                    ConsoleHelper.TextWriteLine(string.Format("{0,2}:{1,2}", item.Key, item.Value.ToString()));
                }
            }