S
stuie_norris
Hi Readers,
I wish to define a const structure and populate it with data.
I have tried implement this in the example below, but keep on getting
"Array initializers can only be used in a variable or field
initializer. Try using a new expression instead."
What is wrong with what I am doing?
Thanks
Stuart
using System;
using System.Collections.Generic;
using System.Text;
namespace structexamp
{
class Program
{
static void Main(string[] args)
{
}
public struct myinfo
{
String code;
int num;
}
myinfo[] myInfo = {{"STR1", 1},{"STR2", 2}};
}
}
I wish to define a const structure and populate it with data.
I have tried implement this in the example below, but keep on getting
"Array initializers can only be used in a variable or field
initializer. Try using a new expression instead."
What is wrong with what I am doing?
Thanks
Stuart
using System;
using System.Collections.Generic;
using System.Text;
namespace structexamp
{
class Program
{
static void Main(string[] args)
{
}
public struct myinfo
{
String code;
int num;
}
myinfo[] myInfo = {{"STR1", 1},{"STR2", 2}};
}
}