3
所以我有一個類有一個字符串數組的參數。我想要做的是將多個字符串存儲到此類的數組中,這是此類的一部分。代碼看起來像這樣:使用字符串數組作爲對象參數
//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.
任何幫助將不勝感激!
將它放在Event構造函數中時,從seatnumber中刪除括號。 –
括號是類型聲明,構造和元素檢索的一部分。您需要傳遞由'seatnumber'命名的引用變量 –