I am Learning c#. I am trying to get the displayName from AD. Here is the code for the following.
if ( resEnt.Properties["displayname"].Count > 0)
{
nameList = new List<string>();
name = resEnt.Properties["displayname"][0].ToString();
nameList.Add(name.ToString());
int count = nameList.Count;
Console.WriteLine("name: " + resEnt.Properties["displayname"][0].ToString());
comboBox1.Items.Add(name.ToString());
}
The error i am getting is
Index was out of range. Must be non-negative and less than the size of the collection.
on the line
name = resEnt.Properties["displayname"][0].ToString();