-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
  • 780
  • 1
  • 11
  • 29

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
  • 26,306
  • 3
  • 62
  • 93