Click here to Skip to main content
15,886,770 members
Home / Discussions / C#
   

C#

 
QuestionArray, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 6:29
KKW_acd15-Nov-12 6:29 
Here's what I've got:

C#
public struct ItmAray
{
    public string FieldName;
    public int FieldIndex;
}

public struct dtlst
{
    public ItmAray[] ItemArray = new ItmAray[128];
}

public dtlst[] DataList = new dtlst[128];


This is what I want:

C#
DataList[x].ItemArray[y].FieldName = clbText;
DataList[x].ItemArray[y].FieldIndex = int.Parse(a);


This is what I'm getting:
an error: "cannot have instance field initializers in structs" from the dtlst structure:
C#
public ItmAray[] ItemArray = new ItmAray[128];


I believe the problem is the righthand side of the line.
But I can't figure out how to fix it.

Thanks!
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 6:55
professionalDaveyM6915-Nov-12 6:55 
GeneralRe: Array, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 9:03
KKW_acd15-Nov-12 9:03 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 19:02
professionalDaveyM6915-Nov-12 19:02 
GeneralRe: Array, Struct, Class??? I'm so confused.... Pin
Richard MacCutchan16-Nov-12 0:02
mveRichard MacCutchan16-Nov-12 0:02 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
Richard MacCutchan15-Nov-12 7:06
mveRichard MacCutchan15-Nov-12 7:06 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
BobJanova16-Nov-12 0:16
BobJanova16-Nov-12 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.