Array of custom properties? (C#)

Hello,

i have a custom class:

public class jetInfo
{
	public string JetName{ get; set;}
}

i need to create an array of it so i tried:

private jetInfo[] JetData = new jetInfo[3];

but when i’m trying to use it like this:

JetData[0].JetName= "Arrow";

i’m getting error in runtime:

NullReferenceException: Object reference not set to an instance of an object

what am i doing wrong?

thanks!

When you do

private jetInfo[] JetData = new jetInfo[3];

you initialize array, where all its elements are null.
All you need to do is:

JetData[0] = new jetInfo();

before

JetData[0].JetName= "Arrow";

P.S. I’d recommend to initialize array contents before using:

for (int i = 0; i < JetData.Length; ++i) {
  JetData *= new JetInfo();*

}