Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
AnswerRe: Update Shorthand? Pin
Dave Kreskowiak19-Jul-13 9:50
mveDave Kreskowiak19-Jul-13 9:50 
AnswerRe: Update Shorthand? Pin
Abhinav S19-Jul-13 18:48
Abhinav S19-Jul-13 18:48 
AnswerRe: Update Shorthand? Pin
Jean A Brandelero22-Jul-13 3:59
Jean A Brandelero22-Jul-13 3:59 
QuestionCalling VB 6 OCX from C# EXE Pin
matinon2219-Jul-13 2:18
matinon2219-Jul-13 2:18 
AnswerRe: Calling VB 6 OCX from C# EXE Pin
Dave Kreskowiak19-Jul-13 2:21
mveDave Kreskowiak19-Jul-13 2:21 
GeneralRe: Calling VB 6 OCX from C# EXE Pin
matinon2223-Jul-13 22:18
matinon2223-Jul-13 22:18 
GeneralRe: Calling VB 6 OCX from C# EXE Pin
Dave Kreskowiak24-Jul-13 3:52
mveDave Kreskowiak24-Jul-13 3:52 
QuestionGeneric collections Pin
PozzaVecia19-Jul-13 0:09
PozzaVecia19-Jul-13 0:09 
I need to use a generic collection of keyvalue pair. I need thr folloeing:

1) should be generic because my values are a customized class
2) iterating should keep the order in which I added Items
3) I should be able to find the index of the element
4) I need access via Key

A dictionary is ok for 1,2,4 but not for 3
SortedList and SortedDictionary are ok for 1, 3, 4 but not for 2.
If I create a
C#
List<keyvaluepair> 
it is ok for 1,2,3 but not for 4 ( I mean not directly)

C#
//Dictionary<string, double> d = new Dictionary<string, double>();
SortedList<string, double> d = new SortedList<string, double>();
            d.Add("z", 1);
            d.Add("a", 2);
            d.Add("c", 3);
            d.Add("b", 4);

            foreach (KeyValuePair<string,double> k in d)
            {
                Console.WriteLine(k.Key + " " + k.Value);
            }

// output: a 2  b 4 c 3 z 1
// but i need to preserve the order in whicth I added.
// I need output: z 1 a 2 c 3 b 4
// using Dictionary I preserve the order but how can select item using an index?

KeyValuePair<string, double> i_item = d.ElementAt(2); // if d is a Dictionary it is not possible


Any suggestion?
Thanks for your time
AnswerRe: Generic collections Pin
Nicholas Marty19-Jul-13 0:41
professionalNicholas Marty19-Jul-13 0:41 
GeneralRe: Generic collections Pin
PozzaVecia19-Jul-13 1:12
PozzaVecia19-Jul-13 1:12 
GeneralRe: Generic collections Pin
Nicholas Marty19-Jul-13 1:17
professionalNicholas Marty19-Jul-13 1:17 
GeneralRe: Generic collections Pin
PozzaVecia19-Jul-13 1:26
PozzaVecia19-Jul-13 1:26 
GeneralRe: Generic collections Pin
Nicholas Marty19-Jul-13 2:07
professionalNicholas Marty19-Jul-13 2:07 
AnswerRe: Generic collections Pin
Keith Barrow19-Jul-13 1:04
professionalKeith Barrow19-Jul-13 1:04 
GeneralRe: Generic collections Pin
Nicholas Marty19-Jul-13 2:09
professionalNicholas Marty19-Jul-13 2:09 
GeneralRe: Generic collections Pin
Keith Barrow19-Jul-13 2:33
professionalKeith Barrow19-Jul-13 2:33 
AnswerRe: Generic collections Pin
Richard Deeming19-Jul-13 3:22
mveRichard Deeming19-Jul-13 3:22 
AnswerRe: Generic collections Pin
BillWoodruff21-Jul-13 0:57
professionalBillWoodruff21-Jul-13 0:57 
GeneralRe: Generic collections Pin
PozzaVecia21-Jul-13 23:05
PozzaVecia21-Jul-13 23:05 
GeneralRe: Generic collections Pin
BillWoodruff22-Jul-13 0:44
professionalBillWoodruff22-Jul-13 0:44 
GeneralRe: Generic collections Pin
PozzaVecia22-Jul-13 1:14
PozzaVecia22-Jul-13 1:14 
GeneralRe: Generic collections Pin
harold aptroot22-Jul-13 1:05
harold aptroot22-Jul-13 1:05 
GeneralRe: Generic collections Pin
PozzaVecia22-Jul-13 3:31
PozzaVecia22-Jul-13 3:31 
GeneralRe: Generic collections Pin
BillWoodruff23-Jul-13 2:41
professionalBillWoodruff23-Jul-13 2:41 
GeneralRe: Generic collections Pin
harold aptroot23-Jul-13 3:11
harold aptroot23-Jul-13 3:11 

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.