Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 编辑BindingList中的项<;T>;_C#_.net_Bindinglist - Fatal编程技术网

C# 编辑BindingList中的项<;T>;

C# 编辑BindingList中的项<;T>;,c#,.net,bindinglist,C#,.net,Bindinglist,它是列表中的代码编辑项 List<class1> lst = new List<class1>(); int index = lst.FindLastIndex(s => s.Number == textBox6.Text); if(index != -1) { lst[index] = new Class1() { ... }; } List lst=new List(); int index=lst.findlastinex(s=>s.Number==tex

它是列表中的代码编辑项

List<class1> lst = new List<class1>();

int index = lst.FindLastIndex(s => s.Number == textBox6.Text);
if(index != -1) { lst[index] = new Class1() { ... }; }
List lst=new List();
int index=lst.findlastinex(s=>s.Number==textBox6.Text);
如果(索引!=-1){lst[index]=new Class1(){…};}
请将代码转换为BindingList

BindingList<class1> lst = new BindingList<class1>();
BindingList lst=newbindingList();
像这样的事情

var item = bindingList.Select((Item,Index) => new { Item, Index })
                      .LastOrDefault(x => x.Item.Number == textBox6.Text);
if (item != null)
{
    bindingList[item.Index] = new Class1() { ... };
}
像这样的

var item = bindingList.Select((Item,Index) => new { Item, Index })
                      .LastOrDefault(x => x.Item.Number == textBox6.Text);
if (item != null)
{
    bindingList[item.Index] = new Class1() { ... };
}

“这是列表中的代码编辑项”-@mah,你有没有可能用谷歌把你的单词翻译成英语?你所有的词库都属于usBTW,
s=>c.Number
是错误的,应该是
s=>s.Number
c=>c.Number
。另外,
BindingList
中的“B”和“L”都是大写。“它是列表中的代码编辑项”-@mah,你有没有可能用谷歌把你的单词翻译成英语?你所有的词库都属于usBTW,
s=>c.Number
是错误的,应该是
s=>s.Number
c=>c.Number
。另外,
BindingList
中的“B”和“L”是大写。错误:'AnonymousType#1'不包含'Number'的定义,并且找不到接受'AnonymousType#1'类型的第一个参数的扩展方法'Number'(是否缺少using指令或程序集引用?)您的意思是x.Index。Number@mah_85:没有,再次复制我的代码。可能您复制了我的第一个版本,其中包含键入错误(即,
索引
顺序错误)错误:'AnonymousType#1'不包含'Number'的定义,并且找不到接受'AnonymousType#1'类型第一个参数的扩展方法'Number'(是否缺少using指令或程序集引用?)。Number@mah_85:否,请再次复制我的代码。可能您复制了我的第一个版本,其中包含键入错误(即,
项目
索引
,顺序错误)