Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: add dynamic number of radio buttons to a panel in C# Pin
SomeGuyThatIsMe19-May-08 7:02
SomeGuyThatIsMe19-May-08 7:02 
QuestionSend Parameters To Crystal Report... Pin
Harvey Saayman19-May-08 2:17
Harvey Saayman19-May-08 2:17 
AnswerRe: Send Parameters To Crystal Report... Pin
geekfromindia19-May-08 3:27
geekfromindia19-May-08 3:27 
QuestionDataset relations problem. Removing row exception! Pin
oscarderooij19-May-08 2:07
oscarderooij19-May-08 2:07 
QuestionAccurate UDP connection Pin
Berlus19-May-08 2:03
Berlus19-May-08 2:03 
AnswerRe: Accurate UDP connection Pin
Mike Dimmick19-May-08 2:23
Mike Dimmick19-May-08 2:23 
GeneralRe: Accurate UDP connection Pin
Berlus20-May-08 19:03
Berlus20-May-08 19:03 
QuestionDictionary Values copy Pin
George_George19-May-08 2:02
George_George19-May-08 2:02 
Hello everyone,


Here is my code to make a duplicate value copy of all the Values in a dictionary instance -- not just reference. So, I use CopyTo method.

My current issue is, I think my code is stupid but do not know how to solve it. My specific concern is,

1.

the code Foo[] FooArray = new Foo[3] creates 3 new instances of Foo, the code dic.Values.CopyTo(FooArray, 0) will overwrite the 3 new instances of Foo? So, seems it is stupid to create 3 new instances of Foo in Foo[] FooArray = new Foo[3], but never use them and overwrite them? Any ideas? Is it an issue?

2.

Maybe I am wrong, the code Foo[] FooArray = new Foo[3] creates only references variable of Foo class? Not class instances variable themselves?

class Foo
{
    public int abc;

    public Foo (int i)
    {
        abc = i;
    }

}

public static void Main()
{

    Dictionary<int, Foo> dic = new Dictionary<int,Foo>();
    dic.Add(1, new Foo(10));
    dic.Add(1, new Foo(20));
    dic.Add(3, new Foo(30));

    Foo[] FooArray = new Foo[3];

    dic.Values.CopyTo(FooArray, 0);

    return;
}



thanks in advance,
George
AnswerRe: Dictionary Values copy Pin
J4amieC19-May-08 2:07
J4amieC19-May-08 2:07 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:13
George_George19-May-08 2:13 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:18
J4amieC19-May-08 2:18 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:22
George_George19-May-08 2:22 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:41
J4amieC19-May-08 2:41 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:49
George_George19-May-08 2:49 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 3:10
J4amieC19-May-08 3:10 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 3:18
George_George19-May-08 3:18 
AnswerRe: Dictionary Values copy Pin
leppie19-May-08 2:29
leppie19-May-08 2:29 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:34
George_George19-May-08 2:34 
GeneralRe: Dictionary Values copy Pin
J4amieC19-May-08 2:47
J4amieC19-May-08 2:47 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 2:52
George_George19-May-08 2:52 
GeneralRe: Dictionary Values copy Pin
leppie19-May-08 3:32
leppie19-May-08 3:32 
GeneralRe: Dictionary Values copy Pin
George_George19-May-08 4:26
George_George19-May-08 4:26 
QuestionRegarding XML loading [modified] Pin
manikandanid19-May-08 1:42
manikandanid19-May-08 1:42 
AnswerRe: Regarding XML loading [modified] Pin
J4amieC19-May-08 2:05
J4amieC19-May-08 2:05 
AnswerRe: Regarding XML loading Pin
Mike Dimmick19-May-08 2:25
Mike Dimmick19-May-08 2:25 

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.