Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
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 
It may be a little faster to get the index using:
private int theIndex;
//
theIndex = dictionaryStringInt.Keys.ToList<string>().IndexOf("KeyString");
However, note that in using both 'ElementAt, and 'ToArray ... or 'ToList ... you are using Linq functions that are, internally, going to do an enumeration.

If the entries in the dictionary are not being removed, moved around, etc., then you could create a List<keytype> once from the Keys collection, however, I doubt that's the case you want here.

I will add some extra functions that return an index to my first answer above, with the hope some of our members here who have more formal computer science training (than I do) will comment on the relative cost / lookup-times, of the example I've given.

good luck, Bill

~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal

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 
GeneralRe: Generic collections Pin
BillWoodruff23-Jul-13 4:09
professionalBillWoodruff23-Jul-13 4:09 
GeneralRe: Generic collections Pin
harold aptroot23-Jul-13 5:32
harold aptroot23-Jul-13 5:32 
GeneralRe: Generic collections Pin
BillWoodruff23-Jul-13 18:11
professionalBillWoodruff23-Jul-13 18:11 
GeneralRe: Generic collections Pin
harold aptroot23-Jul-13 22:42
harold aptroot23-Jul-13 22:42 
GeneralRe: Generic collections Pin
harold aptroot21-Jul-13 1:18
harold aptroot21-Jul-13 1:18 
GeneralRe: Generic collections Pin
PozzaVecia21-Jul-13 22:56
PozzaVecia21-Jul-13 22:56 
GeneralRe: Generic collections Pin
BillWoodruff21-Jul-13 23:40
professionalBillWoodruff21-Jul-13 23:40 
GeneralRe: Generic collections Pin
PozzaVecia22-Jul-13 1:18
PozzaVecia22-Jul-13 1:18 
AnswerRe: Generic collections Pin
M.Kamran Asim21-Jul-13 21:19
M.Kamran Asim21-Jul-13 21:19 
QuestionDisable Windows Navigation Pin
aymen Tn18-Jul-13 5:11
aymen Tn18-Jul-13 5:11 
AnswerRe: Disable Windows Navigation Pin
GuyThiebaut18-Jul-13 5:26
professionalGuyThiebaut18-Jul-13 5:26 
AnswerRe: Disable Windows Navigation Pin
Emmanuel Medina18-Jul-13 5:27
professionalEmmanuel Medina18-Jul-13 5:27 

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.