<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FClass_Interface%2FIComparable</id>
		<title>Csharp/C Sharp/Class Interface/IComparable - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FClass_Interface%2FIComparable"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/IComparable&amp;action=history"/>
		<updated>2026-04-29T17:48:36Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/IComparable&amp;diff=574&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/IComparable&amp;diff=574&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/IComparable&amp;diff=575&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/IComparable&amp;diff=575&amp;oldid=prev"/>
				<updated>2010-05-26T11:38:57Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Implement ICloneable, IComparable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.Serialization;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
&lt;br /&gt;
public class ComplexOverflowException : ApplicationException {&lt;br /&gt;
    public ComplexOverflowException() :&lt;br /&gt;
        base() {&lt;br /&gt;
    }&lt;br /&gt;
    public ComplexOverflowException(string msg) :&lt;br /&gt;
        base(msg) {&lt;br /&gt;
    }&lt;br /&gt;
    public ComplexOverflowException(SerializationInfo info, StreamingContext cxt) :&lt;br /&gt;
        base(info, cxt) {&lt;br /&gt;
    }&lt;br /&gt;
    public ComplexOverflowException(string msg, Exception inner) :&lt;br /&gt;
        base(msg, inner) {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class Complex : ICloneable, IComparable {&lt;br /&gt;
    private double realPart = 0.0;&lt;br /&gt;
    private double imagPart = 0.0;&lt;br /&gt;
    public Complex() {&lt;br /&gt;
    }&lt;br /&gt;
    public Complex(double r) : this(r, 0) {&lt;br /&gt;
    }&lt;br /&gt;
    public Complex(double r, double i) {&lt;br /&gt;
        realPart = r;&lt;br /&gt;
        imagPart = i;&lt;br /&gt;
    }&lt;br /&gt;
    public Complex(Complex l) {&lt;br /&gt;
        realPart = l.realPart;&lt;br /&gt;
        imagPart = l.imagPart;&lt;br /&gt;
    }&lt;br /&gt;
    public double Imaginary {&lt;br /&gt;
        get {&lt;br /&gt;
            return imagPart;&lt;br /&gt;
        }&lt;br /&gt;
        set {&lt;br /&gt;
            imagPart = value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public double Real {&lt;br /&gt;
        get {&lt;br /&gt;
            return realPart;&lt;br /&gt;
        }&lt;br /&gt;
        set {&lt;br /&gt;
            realPart = value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public void Scale(double val) {&lt;br /&gt;
        double tempImaginary = val * imagPart;&lt;br /&gt;
        realPart *= val;&lt;br /&gt;
        imagPart = tempImaginary;&lt;br /&gt;
    }&lt;br /&gt;
    static public Complex operator +(Complex l, Complex r) {&lt;br /&gt;
        Complex result = new Complex(l);&lt;br /&gt;
        result.realPart += r.realPart;&lt;br /&gt;
        result.imagPart += r.imagPart;&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    static public Complex operator *(Complex l, Complex r) {&lt;br /&gt;
        Complex result = new Complex();&lt;br /&gt;
        checked {&lt;br /&gt;
            result.Real = l.Real * r.Real - l.Imaginary * r.Imaginary;&lt;br /&gt;
            result.Imaginary = l.Real * r.Imaginary + l.Imaginary * r.Real;&lt;br /&gt;
        }&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    static public bool operator ==(Complex l, Complex r) {&lt;br /&gt;
        return ((l.Real == r.Real) &amp;amp;&amp;amp;&lt;br /&gt;
            (l.Imaginary == r.Imaginary));&lt;br /&gt;
    }&lt;br /&gt;
    static public bool operator !=(Complex l, Complex r) {&lt;br /&gt;
        return !(l == r);&lt;br /&gt;
    }&lt;br /&gt;
    static public bool operator &amp;gt;(Complex l, Complex r) {&lt;br /&gt;
        double normL = l.imagPart * l.imagPart + l.realPart * l.realPart;&lt;br /&gt;
        double normR = r.imagPart * r.imagPart + r.realPart * r.realPart;&lt;br /&gt;
        return normL &amp;gt; normR;&lt;br /&gt;
    }&lt;br /&gt;
    static public bool operator &amp;lt;(Complex l, Complex r) {&lt;br /&gt;
        return r &amp;gt; l;&lt;br /&gt;
    }&lt;br /&gt;
    public override bool Equals(object o) {&lt;br /&gt;
        if (!(o is Complex))&lt;br /&gt;
            return false;&lt;br /&gt;
        Complex c = (Complex)o;&lt;br /&gt;
        return ((c.Real == Real) &amp;amp;&amp;amp; (c.Imaginary == Imaginary));&lt;br /&gt;
    }&lt;br /&gt;
    public override int GetHashCode() {&lt;br /&gt;
        return (int)(Real + Imaginary);&lt;br /&gt;
    }&lt;br /&gt;
    object ICloneable.Clone() {&lt;br /&gt;
        return new Complex(this);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable.rupareTo(object o) {&lt;br /&gt;
        if (!(o is Complex))&lt;br /&gt;
            throw new ArgumentException(&amp;quot;Object is not a complex number&amp;quot;);&lt;br /&gt;
        Complex c = (Complex)o;&lt;br /&gt;
        double norm = imagPart * imagPart + realPart * realPart;&lt;br /&gt;
        double normO = c.imagPart * c.imagPart + c.realPart * c.realPart;&lt;br /&gt;
        if (norm &amp;gt; normO)&lt;br /&gt;
            return 1;&lt;br /&gt;
        else if (normO &amp;gt; norm)&lt;br /&gt;
            return -1;&lt;br /&gt;
        else&lt;br /&gt;
            return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class MainClass {&lt;br /&gt;
    public static IComparable theMax(IComparable seed, IEnumerable coll) {&lt;br /&gt;
        foreach (IComparable c in coll) {&lt;br /&gt;
            if (c.rupareTo(seed) &amp;gt; 0) {&lt;br /&gt;
                seed = c;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return seed;&lt;br /&gt;
    }&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Complex[] cArray = new Complex[100];&lt;br /&gt;
        Complex max = new Complex(0, 0);&lt;br /&gt;
        max = (Complex)theMax(max, cArray);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implements IComparable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
class Person : IComparable {&lt;br /&gt;
    public string Name;&lt;br /&gt;
    public int Age;&lt;br /&gt;
    public Person(string name, int age) {&lt;br /&gt;
        Name = name;&lt;br /&gt;
        Age = age;&lt;br /&gt;
    }&lt;br /&gt;
    public int CompareTo(object obj) {&lt;br /&gt;
        if (obj is Person) {&lt;br /&gt;
            Person otherPerson = obj as Person;&lt;br /&gt;
            return this.Age - otherPerson.Age;&lt;br /&gt;
        } else {&lt;br /&gt;
            throw new ArgumentException(&lt;br /&gt;
               &amp;quot;Object to compare to is not a Person object.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        ArrayList list = new ArrayList();&lt;br /&gt;
        list.Add(new Person(&amp;quot;A&amp;quot;, 30));&lt;br /&gt;
        list.Add(new Person(&amp;quot;B&amp;quot;, 25));&lt;br /&gt;
        list.Add(new Person(&amp;quot;B&amp;quot;, 27));&lt;br /&gt;
        list.Add(new Person(&amp;quot;E&amp;quot;, 22));&lt;br /&gt;
        for (int i = 0; i &amp;lt; list.Count; i++) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0} ({1})&amp;quot;,&lt;br /&gt;
               (list[i] as Person).Name, (list[i] as Person).Age);&lt;br /&gt;
        }&lt;br /&gt;
        list.Sort();&lt;br /&gt;
        for (int i = 0; i &amp;lt; list.Count; i++) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0} ({1})&amp;quot;,&lt;br /&gt;
               (list[i] as Person).Name, (list[i] as Person).Age);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>