2

I am trying to get an item from a char array based on the index that I have. I have used code earlier to get the index of a specified item but now I want the opposite, to get the item of the specified index. I have tried a few things but can't get it working.

I would like something like this:

char arrayChar = Array.GetItem(index [i]) // I know this isn't right but just so you get the idea.

Thanks very much!

Bali C
  • 30,582
  • 35
  • 123
  • 152

2 Answers2

6

Assuming your char array is called ArrayOfChars and the index is i. It should be as simple as

char arrayChar = ArrayOfChars[i];
Doozer Blake
  • 7,677
  • 2
  • 29
  • 40
1
var arrayChar = yourArray[index];
Jan Dragsbaek
  • 8,078
  • 2
  • 26
  • 46