Enumerations Varibles

Hi Everyone,

I want to be able to set values to an enumeration variable. Please excuse my limited knowledge in programming, I’m a bit stuck. Here’s the code below:

public GoogleMapMarker[] markers;

public class GoogleMapLocation
	public string address;
	public float latitude;
	public float longitude;

public class GoogleMapMarker
	public enum GoogleMapMarkerSize
	public GoogleMapMarkerSize size;
	public GoogleMapColor color;
	public string label;
	public GoogleMapLocation[] locations;

I want to be able to set the color of the “markers” variable as well as setting the locations variable. Is there any way of doing this properly. I’ve tried but get errors when I do stuff like:

markers[1].locations =  ("my address",0.3,0.143);

I really need help on this one, so I would appreciate it no end if someone could help me with their expertise.
Thanks so much,

Johnny :smiley:

Firstly, if you need to specify the latitude and longitude as floats, you need to change:

markers[1].locations =  ("my address", 0.3, 0.143);


markers[1].locations =  ("my address", 0.3f, 0.143f);

Secondly, if you’re trying to create a new instance of GoogleMapLocation without using a constructor, you need to do something like this:

markers[1].locations =  new GoogleMapLocation {address = "my address", latitude = 0.3f, longitude = 0.143f};

Check out this article: How to initialize objects by using an object initializer - C# Programming Guide | Microsoft Learn