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

C#

 
GeneralRe: filtering of comboboxes Pin
Wayne Gaylard18-Jul-12 21:47
professionalWayne Gaylard18-Jul-12 21:47 
GeneralRe: filtering of comboboxes Pin
bdeklerk18-Jul-12 22:21
bdeklerk18-Jul-12 22:21 
GeneralRe: filtering of comboboxes Pin
bdeklerk18-Jul-12 22:22
bdeklerk18-Jul-12 22:22 
GeneralRe: filtering of comboboxes Pin
Wayne Gaylard18-Jul-12 22:31
professionalWayne Gaylard18-Jul-12 22:31 
Questionbluetooth file transfer b/w to windows mobile Pin
syedaliaizazuddin18-Jul-12 19:56
syedaliaizazuddin18-Jul-12 19:56 
GeneralRe: bluetooth file transfer b/w to windows mobile Pin
Peter_in_278018-Jul-12 20:24
professionalPeter_in_278018-Jul-12 20:24 
GeneralRe: bluetooth file transfer b/w to windows mobile Pin
syedaliaizazuddin18-Jul-12 23:34
syedaliaizazuddin18-Jul-12 23:34 
QuestionStrange List<string[]> behaviour... Pin
OlofBakker18-Jul-12 14:58
OlofBakker18-Jul-12 14:58 
Good morning,

I have been searching for a long time, until I nailed this behaviour:
C#
public static void Test()
        {
            string[] strArray = { "", ""};
            List<string[]> strArrayList = new List<string[]>();

            strArray[0] = "A";
            strArrayList.Add(strArray);
            strArray[0] = "B";
            strArrayList.Add(strArray);
            strArray[0] = "C";
            strArrayList.Add(strArray);
            MessageBox.Show("strArrayList: " + strArrayList[0][0] + strArrayList[1][0] + strArrayList[2][0]);
            // I expect: "ABC", but it shows: "CCC"!

            string str = "";
            List<string> strList = new List<string>();
            str = "A";
            strList.Add(str);
            str = "B";
            strList.Add(str);
            str = "C";
            strList.Add(str);
            MessageBox.Show("strList: " + strList[0] + strList[1] + strList[2]);
            // I expect: "ABC", and it shows: "ABC"!
        }

When I change a string and then add it to a list, everything is fine. However, when I change a string in a string array and then add this array to a list, all previously stored arrays in the list are updated as well!

Is this normal or am I doing something wrong?
Of course, there is this ridiculous work-around "strArrayList.Add(strArray.ToList().ToArray());" Which works! Big Grin | :-D

Thanks in advance,

Olof
AnswerRe: Strange List behaviour... Pin
ignrod18-Jul-12 15:25
ignrod18-Jul-12 15:25 
GeneralRe: Strange List behaviour... Pin
OlofBakker19-Jul-12 0:14
OlofBakker19-Jul-12 0:14 
QuestionProgrammable Rotators / Pivots - Do they exist? Pin
Member 850513118-Jul-12 9:40
Member 850513118-Jul-12 9:40 
AnswerRe: Programmable Rotators / Pivots - Do they exist? Pin
Richard MacCutchan18-Jul-12 22:03
mveRichard MacCutchan18-Jul-12 22:03 
Generalcoloring label with timer Pin
sisadosizdah18-Jul-12 8:51
sisadosizdah18-Jul-12 8:51 
GeneralRe: coloring label with timer Pin
Dave Kreskowiak18-Jul-12 8:54
mveDave Kreskowiak18-Jul-12 8:54 
GeneralRe: coloring label with timer Pin
DaveyM6918-Jul-12 8:59
professionalDaveyM6918-Jul-12 8:59 
GeneralRe: coloring label with timer Pin
Paul Conrad18-Jul-12 9:30
professionalPaul Conrad18-Jul-12 9:30 
AnswerRe: start the timer Pin
Luc Pattyn18-Jul-12 10:48
sitebuilderLuc Pattyn18-Jul-12 10:48 
Questionhierarchical data in datagrid wpf(treegrid) Pin
algoram18-Jul-12 5:43
algoram18-Jul-12 5:43 
AnswerRe: hierarchical data in datagrid wpf(treegrid) Pin
Dave Kreskowiak18-Jul-12 8:56
mveDave Kreskowiak18-Jul-12 8:56 
QuestionError 1 The modifier 'abstract' is not valid for this item Pin
RaoulICT17-Jul-12 18:17
RaoulICT17-Jul-12 18:17 
AnswerRe: Error 1 The modifier 'abstract' is not valid for this item Pin
Trak4Net17-Jul-12 19:09
Trak4Net17-Jul-12 19:09 
GeneralRe: Error 1 The modifier 'abstract' is not valid for this item Pin
RaoulICT17-Jul-12 19:26
RaoulICT17-Jul-12 19:26 
GeneralRe: Error 1 The modifier 'abstract' is not valid for this item Pin
Trak4Net17-Jul-12 19:31
Trak4Net17-Jul-12 19:31 
AnswerRe: Error 1 The modifier 'abstract' is not valid for this item Pin
BobJanova18-Jul-12 3:46
BobJanova18-Jul-12 3:46 
GeneralRe: Error 1 The modifier 'abstract' is not valid for this item Pin
PIEBALDconsult18-Jul-12 4:22
mvePIEBALDconsult18-Jul-12 4:22 

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.