-1

I have dictionary object like this:

Dictionary<int, string> dictInputColumnNames;
...

I want to get the key at index 0 in this dictionary, I have the same code in vb which is like this:

Dim inputFieldName As String = dictInputColumnNames(dictInputColumnNames.Keys(0))

What is the equivalent code in C#

Adham Enaya
  • 524
  • 8
  • 24

1 Answers1

-1

Use ElementAt() to get the key:

int myKey = dictInputColumnNames.Keys.ElementAt(0);

You can then use the key to retrieve the value:

string inputFieldName = dictInputColumnNames[myKey];
NineBerry
  • 22,104
  • 3
  • 54
  • 86