[英]How to pass array in C#
I have a prototype: 我有一个原型:
int[] medianFileter(int[] data);
and an array 和一个数组
int[] intVal = new int[5];
How can I pass the intVal to the prototype in C#? 如何将intVal传递给C#中的原型?
Um, you just call it (assuming you've got a real implementation to call): 嗯,您只需调用它(假设您有一个真正的实现要调用):
int[] result = medianFileter(intVal);
Note that any changes made to the array within the method will show up in intVal
: you're not passing each of the integers individually, but a reference to the whole array. 请注意,对方法中的数组所做的任何更改都将显示在intVal
:您不是分别传递每个整数,而是对整个数组的引用。
(There could be some trickiness here due to your use of the word "prototype" - it's not standard C# terminology, so I'm not exactly sure what you mean. If you could clarify the question, that would help.) (由于您使用了“原型”一词,因此可能会有一些棘手的问题-这不是标准的C#术语,因此我不确定您的意思。如果您可以澄清问题,那将会有所帮助。)
On a side note, method names in .NET are usually Pascal-cased, so this should probably be: 附带说明一下,.NET中的方法名称通常使用Pascal大小写,因此应为:
int[] result = ApplyMedianFilter(intVal);
这可能是我在这里看不到明显的怪异之处,或者只是通常的函数调用:
int[] medianFiltered = medialFileter(intVal);
这就是你要做的
medianFileter(intVal);
What's the problem with: 有什么问题:
medianFileter(intVal);
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.