c# - 使用字符串数组作为对象参数

标签 c# arrays class arguments

所以我有一个类,它有一个字符串数组的参数。我想要做的是将多个字符串存储到这个属于此类的数组中。代码看起来像这样:

//Class part of it. Class is called "Event"
public class Event
{
   public string[] seats = new string [75];

   public Event(string[] seats)
   {
      this.seats = seats;
   }
}

// the main code that uses "Event" Class

string[] seatnumber = new string[75];
Event show = new Event (seatnumber[]); //And that is where the error comes in. 

如有任何帮助,我们将不胜感激!

最佳答案

将座位号放入事件构造函数时,请将其从括号中移除。

For reference.

关于c# - 使用字符串数组作为对象参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30066118/

相关文章:

c++ - 包括头文件(包括它们自己)

c# - 双三次插值?

c# - WP8 LongListSelector scrollTo() 和分组启用

c++ - 两个基类中的相同成员?

java - 将项目添加到多维 ArrayList

arrays - Perl 中是否有任何函数可以移动数组元素而不删除它们?

python - 有什么理由给 self 一个默认值吗?

c# - T4 获取当前解的执行文件名

c# - 奇怪的 DllImport 行为(仅在 Unity3d 中)

javascript - 除括号中的空格之外的所有空格拆分字符串