3.6. :
(, , );
.
13.4. .
1- . .
.
2- . .
List<T> Sort (). ( ) Comparer.Default. , , . . namespace Lab13 ( , ) - CompareByLastName:
class CompareByLastName: IComparer<Note>
IComparer, . , , , Implement interface IComparer<Note> ( ) (. 13.7).
Compare (), Note, : , , , , .
class CompareByLastName: IComparer<Note>
{
#region IComparer<Note> Members
public int Compare(Note x, Note y)
{
throw new NotImplementedException();
}
#endregion
}
# region # endregion , .
Compare () , , :
throw new NotImplementedException();
, ():
return string.Compare(x.LastName, y.LastName);
, - CompareByLastName .
( ). .
if (PhoneNote.Count > 0) //
{
//
PhoneNote.Sort(new CompareByLastName());
current = 0; //
PrintElement(); //
}
. , .
.
class CompareByFlat: IComparer<Note>
{
#region IComparer<Note> Members
public int Compare(Note x, Note y)
{
return x.Flat.CompareTo(y.Flat);
}
#endregion
}
:
if (PhoneNote.Count > 0)
{
PhoneNote.Sort(new CompareByFlat());
current = 0;
PrintElement();
}
. , .