Sort Identities alphabetically+c#

84 views Asked by At

I am working on the below code snippet where m_identities[memDesc].DisplayName a Windows SID DisplayName. The Display Name is in the LastName, FirstName format. I need help figuring out a couple of things,

  1. Switch the m_identities[memDesc].DisplayName format so that it is in the form of FirstName LastName
  2. Sort the DisplayName by Alphabetical order when exporting it to CSV.

Any help is much appreciated!

static void Write(TeamFoundationIdentity group)
{
    string csv = string.Format("\n Members of group: {0} \n ", group.DisplayName);
    File.AppendAllText(@"C:\MembersLog\QueryMembers" + ".csv", csv);
    string csv1 = string.Format("==================================================\n");
    File.AppendAllText(@"C:\MembersLog\QueryMembers" + ".csv", csv1);

    foreach (IdentityDescriptor memDesc in group.Members)
    {
        string csv2 = string.Format(" {0} \n", m_identities[memDesc].DisplayName);
        File.AppendAllText(@"C:\MembersLog\QueryMembers" + ".csv", csv2);
    }

    Console.WriteLine();
}
0

There are 0 answers