I have an issue with int[] array. I have the following definition of EmailIndex dictionary:
Dictionary<string, int[]> EmailIndex = new Dictionary<string, int[]>();
When there are few members in the dictionary's int[] array the TryGetValue returns array into int[] arr and my method works perfectly. But when I tested it with about 1800 members in the array it returns null. I checked the instance of the EmailIndex dictionary that I use in my method and it has all values.
Here is the code
private void SearchByEmail(string email)
{
try
{
int[] arr;
EmailIndex.TryGetValue(email, out arr);
foreach (int entry in arr)
{
string fileName = @"C:\Admin\Q\chunkUsers" + entry.ToString() + ".csv";
var search = File.ReadLines(fileName)
.Where(line =>
{
line = line.Trim();
return line.Contains(email);
});
foreach (string line in search)
{
Console.WriteLine(line);
}
}
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
The behavior is different when the array is tiny. The TryGetValue returns true. When the array grows then TryGetValue returns false.
UPD: there is no problem with TryGetValue. There was an issue with trailing \"
in the email
that I passed to the method