home *** CD-ROM | disk | FTP | other *** search
-
- <!-- #include virtual="/quickstart/howto/include/header.inc" -->
-
- <h4>How Do I...Compare the value of two objects?</h4>
-
- <div class="indent" style="width:660">
- This sample illustrates how to compare almost any two values.
- This is done by leveraging the IComparable interface that all
- the base types implement. The Max method shown below returns
- the maximum of any two values that implement IComparable. Because
- all of the base types (int, double, sting, etc) implement IComparable,
- this method works with all of them. The CompareTo method on IComparable
- has the following return values: < 0 if value is less than the current
- instance, == 0 if value is equal to the current instance,
- > 0 if value is greater than the current instance. We also show
- a custom implementation of IComparable.
- </div>
-
- <h4>Example</h4>
-
- <p>
- <div class="indent">
- <a target="_blank" href="<%=Server.MapPath("/quickstart/howto/samples/BaseDataTypes/compare")%>">
- <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
- </a>
- <div class="caption">Compare.exe</div><br>
- [<a target="_blank" href="<%=Server.MapPath("/quickstart/howto/samples/BaseDataTypes/compare")%>">View Sample</a>] |
- [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/BaseDataTypes/compare/compare.src">View Source</a>]<p>
- </div>
-
- <h4>Source Code</h4>
-
- <div class="code">
- <xmp>
-
- <!-- #include virtual="/quickstart/howto/samples/BaseDataTypes/Compare/compare.cs" -->
-
- </xmp>
- </div>
-
- <!-- #include virtual="/quickstart/howto/include/footer.inc" -->