Linked Questions

41 votes
1 answer
80k views

Possible Duplicate: Declare a Const Array I need an array of const strings in the class. Something like public class some_class_t { public const string[] names = new string[4] { "...
Newbee's user avatar
  • 1,032
21 votes
1 answer
21k views

I'm trying to create a 2D array to store some values that don't change like this. const int[,] hiveIndices = new int[,] { {200,362},{250,370},{213,410} , {400,330} , {380,282} , {437, 295} , {325, ...
nikhil's user avatar
  • 9,506
1 vote
1 answer
6k views

I have a set of C# constants, for example: LoanApplication.CONST_FIELD_NAME_DOB LoanApplication.CONST_FIELD_NAME_EMPLOYMENTSTATUS at a later time, I want to create an array that holds these constants....
Alex's user avatar
  • 4,058
0 votes
0 answers
115 views

I have the following class that is used in conjunction with the data object for PropertyGrid: public enum WebUILanguage { EnglishUS, German, //Actual list is obviously longer } [...
c00000fd's user avatar
  • 22.8k
0 votes
0 answers
81 views

I want to declare constant integer array in my code. Code C#: namespace example { public partial class MainWindow : MetroWindow { public const int[] ai_pavyzdys = { 186, 186 }; }...
armandasalmd's user avatar
0 votes
0 answers
67 views

I start learning C# couple of weeks ago and I can't figure out how to declare a public const char array. This is what I have: public static class MyClass { public const char[] MyCharArray= new ...
makaMa's user avatar
  • 21
5 votes
1 answer
4k views

How I can pass string[][] arrays to ValuesAttribute? I have: public string[][] Array1 = new[] {new[] {"test1", "test2"}}; //... [Test, Sequential] public void SomeTest( [Values("val1", "val2", "...
Vladimirs's user avatar
  • 8,659
3 votes
4 answers
1k views

In C#, you can define a const string, but not an array as arrays are objects. It is to my understanding that strings are in fact objects as they are reference objects passed by value just like arrays. ...
Cole Tobin's user avatar
  • 9,448
4 votes
2 answers
1k views

Is it possible to create a constant dictionary or array at compile time in C#? If not, is it possible to do this in C or C++ and compile to a dll that can be pulled into a C# project? I need to create ...
Major Major's user avatar
0 votes
5 answers
275 views

Why following is an Error in C#? public const int[] test = { 1, 2, 3, 4, 5 }; Error : A const field of a reference type other than string can only be initialized with null.
Ravi Sharma's user avatar
2 votes
1 answer
62 views

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 ...
NicoBlu's user avatar
  • 47