Array of String Constants?

  • Thread starter Thread starter Joe Cool
  • Start date Start date
J

Joe Cool

I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!
 
Joe said:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

private string[] DataTypes = { "Text", "Integer", "Date" };

Arne

PS: There are tools (also web based) that can convert between
C# and VB.NET !
 
Joe said:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!

If you want your string would be constant, add readonly keyword
private readonly string[] DataTypes = new string[] { "Text", "Integer",
"Date" };
 
Duy Lam said:
Joe said:
I am converting a VB.NET program to C#.NET.

How do I code the following from VB.NET to C#.NET?

Private DataTypes() As String = { "Text", "Integer", "Date" }

Thanks for any help!

If you want your string would be constant, add readonly keyword
private readonly string[] DataTypes = new string[] { "Text", "Integer",
"Date" };

Unfortunately that doesn't stop the array contents from being changes.
It prevents code like this:

DataTypes = new string[5];

but it doesn't stop:

DataTypes[0] = "Image";
 
Back
Top