如何访问一个结构的成员像在C#中的数组? [英] How to access members of an struct like an array in C#?

查看:130
本文介绍了如何访问一个结构的成员像在C#中的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有百元以上的元素复杂名称的结构。而我传递使用裁判所描述的功能,这样的结构类型的结构:

Lets say I have a struct with more than hundred elements with complex names. And I am passing a struct of the struct type described to a function using ref, like this:

void Foo(ref mystruct a)
{
   "I want to modify members or fields of struct a, like this:
   a[0] = 10;
   a[100] = 11;"
}



谢谢!

Thanks!

推荐答案

也许你应该重新审视你的数据结构的选择。也许字典会更适合?

Maybe you should re-examine your choice of data structure. Perhaps a dictionary would be better suited?

这篇关于如何访问一个结构的成员像在C#中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆