Tomato
Tomato

Reputation: 129

Use XElement as array of XElements and access them

I want to ask if it is possible to use XElement as array... There is sample how I created that and use that.

XElement[] tracks = new XElement[pauses.Count + 1];

tracks[0].Add(Trackpoint)

Unfortunately it throws exception:

An unhandled exception of type 'System.NullReferenceException' occurred in ***.exe. Additional information: Object reference not set to an instance of an object.

It is quite obvious that I can't do this this way. Is there any another solution how could I do this?

Upvotes: 0

Views: 492

Answers (1)

T K
T K

Reputation: 238

You initialized the array, but all elements are null. Add a reference to a new XElement at each index before using it.

Upvotes: 1

Related Questions