I am going to a directory picking up some files and then adding them to a Dictionary.
The first time in the loop the key needs to be A, second time B etc. Afer 26/Z the number represents different characters and from 33 it starts at lowercase a up to 49 which is lowercase q.
Without having a massive if statement to say if i == 1 then Key is ‘A’ etc etc how can I can keep this code tidy?
Sounds like you just need to keep an index of where you’ve got to, then some mapping function:
EDIT: I’ve updated the
MapIndexToKeymethod to make it simpler. It’s not clear why you want a string key if you only ever use a single character though…Another edit: I believe you could actually just use:
instead of having the mapping function at all, given your requirements, as the characters are contiguous in Unicode order from ‘A’…