Click here to Skip to main content
12,243,333 members (52,026 online)
   

C#

 
AnswerRe: Design Question Pin
Rahul Rajat Singh15-Nov-12 22:43
memberRahul Rajat Singh15-Nov-12 22:43 
GeneralRe: Design Question Pin
TheGermoz16-Nov-12 0:14
memberTheGermoz16-Nov-12 0:14 
AnswerRe: Design Question Pin
Rahul Rajat Singh16-Nov-12 0:22
memberRahul Rajat Singh16-Nov-12 0:22 
AnswerRe: Design Question Pin
BobJanova16-Nov-12 0:12
memberBobJanova16-Nov-12 0:12 
GeneralRe: Design Question Pin
TheGermoz16-Nov-12 0:16
memberTheGermoz16-Nov-12 0:16 
GeneralRe: Design Question Pin
Rahul Rajat Singh16-Nov-12 0:35
memberRahul Rajat Singh16-Nov-12 0:35 
GeneralRe: Design Question Pin
BobJanova16-Nov-12 1:09
memberBobJanova16-Nov-12 1:09 
AnswerRe: Design Question Pin
SledgeHammer0116-Nov-12 10:53
memberSledgeHammer0116-Nov-12 10:53 
GeneralRe: Design Question Pin
TheGermoz16-Nov-12 11:06
memberTheGermoz16-Nov-12 11:06 
AnswerRe: Design Question Pin
Clifford Nelson16-Nov-12 10:53
memberClifford Nelson16-Nov-12 10:53 
QuestionBackground worker thread Pin
MAW3015-Nov-12 15:54
memberMAW3015-Nov-12 15:54 
AnswerRe: Background worker thread Pin
DaveyM6915-Nov-12 19:51
mentorDaveyM6915-Nov-12 19:51 
QuestionArray, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 7:29
memberKKW_acd15-Nov-12 7:29 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 7:55
mentorDaveyM6915-Nov-12 7:55 
KKW_acd wrote:
righthand side of the line

You are correct. As the message says, you cannot initialize a field when it is first declared in a struct, all fields assume the default value for the type which in the case of an array is null. Initialization must be done in a constructor (however you cannot have a parameterless constructor for a struct either).

When to use a struct or a class can be complicated sometimes. I think your dtlst (horrible name by the way - why not DataList?) should most likely be a class. You will then be able to initialize the field as you wish.

Also, public fields are normally bad practice, make them private and use a property (getter only unless a setter is needed) to expose the field.

Edit: There's still a few things about this that don't feel right, but to fit your code and usage, this is a quick example of something that works. This is not meant to be doing your homework for you, but rather to point you in the correct direction and give you something to compare your code too:
public struct Item
{
    private string name;
    private int index;
 
    public Item(string name, int index)
    {
        this.name = name;
        this.index = index;
    }
 
    // only getters as a struct should not normally be changed once created.
    public string Name { get { return name; } }
    public int Index { get { return index; } }
}
public class DataList
{
    private Item[] items = new Item[128];
 
    public Item[] Items { get { return items; } }
}
// usage
DataList[] dataLists = new DataList[128];
 
int listIndex = 0;
int itemIndex = 0;
 
string itemText = "Random text";
string indexText = "1";
 
dataLists[listIndex] = new DataList();
 
dataLists[listIndex].Items[itemIndex] = new Item(itemText, int.Parse(indexText));
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)




modified 15-Nov-12 13:19pm.

GeneralRe: Array, Struct, Class??? I'm so confused.... Pin
KKW_acd15-Nov-12 10:03
memberKKW_acd15-Nov-12 10:03 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
DaveyM6915-Nov-12 20:02
mentorDaveyM6915-Nov-12 20:02 
GeneralRe: Array, Struct, Class??? I'm so confused.... Pin
Richard MacCutchan16-Nov-12 1:02
mvpRichard MacCutchan16-Nov-12 1:02 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
Richard MacCutchan15-Nov-12 8:06
mvpRichard MacCutchan15-Nov-12 8:06 
AnswerRe: Array, Struct, Class??? I'm so confused.... Pin
BobJanova16-Nov-12 1:16
memberBobJanova16-Nov-12 1:16 
QuestionWind Chill Automation with C# application Pin
omisheikh15-Nov-12 7:03
memberomisheikh15-Nov-12 7:03 
AnswerRe: Wind Chill Automation with C# application Pin
jschell15-Nov-12 9:12
memberjschell15-Nov-12 9:12 
GeneralRe: Wind Chill Automation with C# application Pin
omisheikh16-Nov-12 4:25
memberomisheikh16-Nov-12 4:25 
GeneralRe: Wind Chill Automation with C# application Pin
jschell17-Nov-12 6:40
memberjschell17-Nov-12 6:40 
GeneralRe: Wind Chill Automation with C# application Pin
omisheikh18-Nov-12 22:00
memberomisheikh18-Nov-12 22:00 
QuestionAccess mainform while subform is updating Pin
MAW3014-Nov-12 20:01
memberMAW3014-Nov-12 20:01 
AnswerRe: Access mainform while subform is updating Pin
Mycroft Holmes14-Nov-12 20:53
memberMycroft Holmes14-Nov-12 20:53 
AnswerRe: Access mainform while subform is updating Pin
DaveyM6915-Nov-12 1:02
mentorDaveyM6915-Nov-12 1:02 
QuestionGet integer variable from datalist textbox for entry into SQL Pin
Member 959997514-Nov-12 11:10
memberMember 959997514-Nov-12 11:10 
AnswerRe: Get integer variable from datalist textbox for entry into SQL Pin
rajeshkasani0514-Nov-12 19:34
memberrajeshkasani0514-Nov-12 19:34 
GeneralRe: Get integer variable from datalist textbox for entry into SQL Pin
Member 959997514-Nov-12 23:50
memberMember 959997514-Nov-12 23:50 
GeneralRe: Get integer variable from datalist textbox for entry into SQL Pin
rajeshkasani0514-Nov-12 23:55
memberrajeshkasani0514-Nov-12 23:55 
GeneralRe: Get integer variable from datalist textbox for entry into SQL Pin
Member 959997515-Nov-12 3:25
memberMember 959997515-Nov-12 3:25 
GeneralRe: Get integer variable from datalist textbox for entry into SQL Pin
Richard MacCutchan15-Nov-12 4:21
mvpRichard MacCutchan15-Nov-12 4:21 
QuestionC# clear out global cache Pin
dcof14-Nov-12 8:52
memberdcof14-Nov-12 8:52 
AnswerRe: C# clear out global cache Pin
jschell14-Nov-12 9:00
memberjschell14-Nov-12 9:00 
AnswerRe: C# clear out global cache Pin
Pete O'Hanlon14-Nov-12 12:00
protectorPete O'Hanlon14-Nov-12 12:00 
GeneralRe: C# clear out global cache Pin
cptKoala14-Nov-12 22:50
membercptKoala14-Nov-12 22:50 
GeneralRe: C# clear out global cache Pin
Pete O'Hanlon14-Nov-12 23:07
protectorPete O'Hanlon14-Nov-12 23:07 
GeneralRe: C# clear out global cache Pin
cptKoala14-Nov-12 23:12
membercptKoala14-Nov-12 23:12 
GeneralRe: C# clear out global cache Pin
Paul Conrad15-Nov-12 8:52
memberPaul Conrad15-Nov-12 8:52 
GeneralRe: C# clear out global cache Pin
Pete O'Hanlon15-Nov-12 9:39
protectorPete O'Hanlon15-Nov-12 9:39 
Questionpredefined type 'xxx' is defined in multiple assemblies in the global alias Pin
sc steinhayse14-Nov-12 6:23
membersc steinhayse14-Nov-12 6:23 
QuestionRe: predefined type 'xxx' is defined in multiple assemblies in the global alias Pin
n.podbielski14-Nov-12 7:20
membern.podbielski14-Nov-12 7:20 
QuestionConversion of HTML file into TIFF file Pin
ukraju14-Nov-12 2:25
memberukraju14-Nov-12 2:25 
AnswerRe: Conversion of HTML file into TIFF file Pin
Richard MacCutchan14-Nov-12 2:39
mvpRichard MacCutchan14-Nov-12 2:39 
GeneralRe: Conversion of HTML file into TIFF file Pin
ukraju14-Nov-12 2:43
memberukraju14-Nov-12 2:43 
GeneralRe: Conversion of HTML file into TIFF file Pin
Dave Kreskowiak14-Nov-12 2:52
mvpDave Kreskowiak14-Nov-12 2:52 
GeneralRe: Conversion of HTML file into TIFF file Pin
BobJanova14-Nov-12 5:45
memberBobJanova14-Nov-12 5:45 
QuestionGet outlook password Pin
Sanjeev991813-Nov-12 21:32
memberSanjeev991813-Nov-12 21:32 
AnswerRe: Get outlook password Pin
Pete O'Hanlon13-Nov-12 21:46
protectorPete O'Hanlon13-Nov-12 21:46 

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.


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 1 May 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid