This is a very mysterious behavior.
In my C# ASP.NET project (.asmx web service), constants are assigned in a file Constants.cs.
namespace MyProject
{
public class MyConstants
{
public const string MyString = "Mars";
public static readonly string[] MyArray = { "Pluto", "Eart", "Venus" };
}
}
If MyString is called in main unit with
string StrPlanet = MyConstants.MyString;
all works.
If I call ANY element of MyArray and assign it with
string StrPlanet = MyConstants.MyArray[0];
I get this error:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at MyProject.Constants..cctor()
Where is mistake?
Thanks.
MyConstants.MyArray? Maybe your index is going out of bounds there.MyProject.Constants..cctor()?