Click here to Skip to main content
15,902,860 members
Home / Discussions / C#
   

C#

 
AnswerRe: Jagged array initialization Pin
harold aptroot18-Feb-09 10:12
harold aptroot18-Feb-09 10:12 
GeneralRe: Jagged array initialization Pin
t_feras18-Feb-09 10:37
t_feras18-Feb-09 10:37 
GeneralRe: Jagged array initialization Pin
harold aptroot18-Feb-09 11:06
harold aptroot18-Feb-09 11:06 
JokeRe: Jagged array initialization Pin
DaveyM6918-Feb-09 11:09
professionalDaveyM6918-Feb-09 11:09 
GeneralRe: Jagged array initialization Pin
harold aptroot18-Feb-09 11:14
harold aptroot18-Feb-09 11:14 
GeneralRe: Jagged array initialization Pin
t_feras18-Feb-09 11:15
t_feras18-Feb-09 11:15 
GeneralRe: Jagged array initialization Pin
harold aptroot18-Feb-09 12:10
harold aptroot18-Feb-09 12:10 
GeneralRe: Jagged array initialization Pin
t_feras18-Feb-09 12:31
t_feras18-Feb-09 12:31 
harold aptroot wrote:
It cheated. I'm afraid I suggested an ugly work-around that is at least "bad taste".

Oh well. An explanation.

It made the "temporary" object static. That is, it is shared between all instances of the containing class (or struct). It shouldn't be (shared, that is), but it works.. But it also has the unfortunate side effect that a reference to that array is kept - forever (well, at least for a long time).

I was partially under the impression that this initialization code was for a local variable, if that were true there would be no need of such ugly hacks.
And I should have suggested something better, which I did later.. Initializing that field in the constructor.

Now, I just realized something. Code like that should almost never initialize a non-static field. Because it looks like that (jagged) array is meant to be a look-up table. If it isn't then don't worry about it, but if it is, consider making it static as well. Or even static readonly. But what am I saying here, it's your code after all and I don't know how you're using it. Do what you want Smile


I see what you mean now. The thing is I am using the jagged array as an LUT. I tried to make it static but it didn't initialize properly. I looked into the Dictionary data structure and figured out that it won't work for me. I guess I have to deal with this flaw for now. Thanks Harold for your support with this issue.
AnswerRe: Jagged array initialization Pin
Luc Pattyn18-Feb-09 13:10
sitebuilderLuc Pattyn18-Feb-09 13:10 
QuestionDisplaying Ritch textbox contents the same as it is printed Pin
hendrik18-Feb-09 7:29
hendrik18-Feb-09 7:29 
AnswerRe: Displaying Ritch textbox contents the same as it is printed Pin
Dave Kreskowiak18-Feb-09 9:00
mveDave Kreskowiak18-Feb-09 9:00 
QuestionDrop event in RichText Box Pin
Lijo Rajan18-Feb-09 6:37
Lijo Rajan18-Feb-09 6:37 
AnswerRe: Drop event in RichText Box Pin
vaghelabhavesh18-Feb-09 7:32
vaghelabhavesh18-Feb-09 7:32 
QuestionProgramming for synchronization of local database with remote server database. Pin
Digubha18-Feb-09 5:43
Digubha18-Feb-09 5:43 
AnswerRe: Programming for synchronization of local database with remote server database. Pin
Ennis Ray Lynch, Jr.18-Feb-09 6:40
Ennis Ray Lynch, Jr.18-Feb-09 6:40 
GeneralRe: Programming for synchronization of local database with remote server database. Pin
Mycroft Holmes18-Feb-09 21:39
professionalMycroft Holmes18-Feb-09 21:39 
GeneralRe: Programming for synchronization of local database with remote server database. Pin
Ennis Ray Lynch, Jr.19-Feb-09 2:53
Ennis Ray Lynch, Jr.19-Feb-09 2:53 
GeneralRe: Programming for synchronization of local database with remote server database. Pin
Mycroft Holmes19-Feb-09 10:24
professionalMycroft Holmes19-Feb-09 10:24 
Questiongmail authentication using c# windows application Pin
techismart18-Feb-09 5:07
techismart18-Feb-09 5:07 
AnswerRe: gmail authentication using c# windows application Pin
benjymous18-Feb-09 5:27
benjymous18-Feb-09 5:27 
QuestionC# SqlCeReader weirdness Pin
J-Cop18-Feb-09 4:51
J-Cop18-Feb-09 4:51 
AnswerRe: C# SqlCeReader weirdness Pin
Dave Kreskowiak18-Feb-09 5:01
mveDave Kreskowiak18-Feb-09 5:01 
GeneralRe: C# SqlCeReader weirdness Pin
J-Cop18-Feb-09 21:14
J-Cop18-Feb-09 21:14 
AnswerRe: C# SqlCeReader weirdness Pin
Ennis Ray Lynch, Jr.18-Feb-09 5:22
Ennis Ray Lynch, Jr.18-Feb-09 5:22 
QuestionSorting a BindingList Pin
MatthysDT18-Feb-09 4:33
MatthysDT18-Feb-09 4:33 

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.