Bear in mind I'm very new to C#.
I'm trying to get the key of the current element in a foreach loop. I know how to do this in PHP but I'm clueless with C#. For example:
foreach($array as $key => $value)
{
echo("$value is assigned to key: $key");
}
What I'm trying to do in C#:
int[] values = { 5, 14, 29, 49, 99, 150, 999 };
foreach(int val in values)
{
if(search <= val && !stop)
{
// set key to a variable
}
}
Can anyone help me out?
Thanks