Linked Questions
11 questions linked to/from Declare a const array
41
votes
1
answer
80k
views
Const array of strings [duplicate]
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]
{
"...
21
votes
1
answer
21k
views
A const field of a reference type other than string can only be initialized with null Error [duplicate]
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, ...
1
vote
1
answer
6k
views
C# array of const string [duplicate]
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....
0
votes
0
answers
115
views
How to initialize const array, not readonly, getting error CS0134 [duplicate]
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
}
[...
0
votes
0
answers
81
views
C# const int[] error [duplicate]
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 };
}...
0
votes
0
answers
67
views
Is it possible to declare a public const char array [duplicate]
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 ...
5
votes
1
answer
4k
views
NUnit Sequential Attribute with arrays in Values
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", "...
3
votes
4
answers
1k
views
How can we define string constants but not arrays
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.
...
4
votes
2
answers
1k
views
Compile Time Dictionary or Array C#
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 ...
0
votes
5
answers
275
views
Why following is an Error in C#?
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.
2
votes
1
answer
62
views
Array error reference error in asmx project
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 ...