object reference is required for the non-static field, method, or property
我的代码中出现上述错误,我不知道为什么(有很多类似的问题,但我读过的所有问题似乎都与我有关)。
class Program
{
static void Main(string[] args)
{
VenueMappings venueMappings = new VenueMappings();
var venue1 = new Venue
{
ExtEventNo = 1,
UsiVenue = "building1",
};
VenueMappings.venues[0] = venue1;
}
}
public struct Venue
{
public int ExtEventNo;
public String UsiVenue;
};
public class VenueMappings
{
public Venue[] venues = new Venue[2];
};