![](/img/trans.png)
[英]I have a method that accepts Datagridview name as parameter.How to build this Data grid view name Dynamically?
[英]i am unable to pass array as function parameter.how i can solve?
我正在窗口窗體應用程序上工作,並使函數將數組作為函數參數傳遞,如下所示:
void foobar(int[] foo, string[] bar)
{
}
//calling
foobar(new {1, 2,3}, new {"a", "b", "c"});
當我調用該函數時,它顯示錯誤:
"Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access."
我該如何解決?
//calling
foobar(new int[] {1, 2,3}, new string[] {"a", "b", "c"});
new {1, 2,3}
和new {"a", "b", "c"}
在C#中無效(不是正確的聲明數組的方式)。 因此,要傳遞數組,您必須使用正確的語法,即new int[] {1, 2,3}, new string[] {"a", "b", "c"}
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.