I am VERY new to programming, and am learning C#. Week 4!
Writing program asking for user input for:
- Friends name
- Phone
- Month of Birth
- Day
- Year of birth.
Creating as an array of objects and using the IComparable to enable object comparison.
Need to sort objects by string, alphabetically, and I think I have all the rest of the code except getting the string to compare. Here's what I have for the IComparable.CompareTo(Object o):
int IComparable.CompareTo(Object o)
{
int returnVal;
Friend temp = (Friend)o;
if(this.Name > temp.Name)
returnVal = 1;
else
if(this.Name < temp.Name)
returnVal = -1;
else returnVal = 0;
return returnVal;
}
The error I receive when compiling is:
CS0019 Operator'>' cannot be applied to operands of type 'string' and 'string'.
Instructor is not much help, text doesn't synthesize this contingency.