gpt4 book ai didi

列表中的 C# 结构

转载 作者:行者123 更新时间:2023-12-01 22:26:26 25 4
gpt4 key购买 nike

<分区>

关于结构的快速问题...我有一个结构,假设它看起来像这样:

struct myStruct {
public int x, y;
}

然后我制作了一个包含该结构的列表

List<myStruct> myList = new List<myStruct>;

然后我循环遍历列表,我想更改 x 的值...

for(int i=0; i<myList.Count; i++) {

...//do stuff to x

myList[i].x = newX;
}

Cannot modify the return value of 'List<myform.myStruct>.this[int]' because it is not a variable

关于为什么它不允许我更改 x 的值,您能否消除我的困惑。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com