I am using following code to create an array to find out start and end index of a multidimensional array:
var valueArray = Enumerable.Range(0, val.GetLength(1))
.Where(index => val[0, index].Contains("Rak"))
.ToArray();
Than i am using valueArray to get start index which is valueArray[0] and end index which will be valueArray[valueArray.Length-1].
Above code works. But it looks like it is doing aweful amout of work to get start and end index. As it is first creating valueArray putting in all values in it and then getting index values. Can anyone suggest better way of doing this?
Defination of array:
private string[,] _val;
public string[,] val
{
[Pure]
get
{
if (_val != null)
return (string[,])_val.Clone();
return null;
}
set
{
_val = value;
}
}
Dictionary<int, HashSet<string>>This way you can call directly val[i].Contains("Rak");