Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
Ok, what are the advantages of implementing IComparable and the CompareTo function (which takes an object as a parameter) as opposed to just creating my own static function CompareTo that takes my class type as a parameter?
  • Administrators
Posted

If you implement IComparable then your class / structure can be used anywhere the IComparable interface is expected, including parts of the .Net Framework (e.g. Array.Sort)

If you coded your own function then you would only be able to use it in a limited number of places (i.e. your own code)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...