<?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%2FCSharp_Tutorial%2FOperator_Overload%2FTrue_false_operator</id>
		<title>Csharp/CSharp Tutorial/Operator Overload/True false operator - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FOperator_Overload%2FTrue_false_operator"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/True_false_operator&amp;action=history"/>
		<updated>2026-04-30T01:10:41Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/True_false_operator&amp;diff=6386&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/True_false_operator&amp;diff=6386&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</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/CSharp_Tutorial/Operator_Overload/True_false_operator&amp;diff=6387&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/True_false_operator&amp;diff=6387&amp;oldid=prev"/>
				<updated>2010-05-26T12:18:54Z</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;==Overload true and false for TwoDimension.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;   &lt;br /&gt;
   &lt;br /&gt;
class TwoDimension {   &lt;br /&gt;
  int x, y;&lt;br /&gt;
   &lt;br /&gt;
  public TwoDimension() { &lt;br /&gt;
     x = y = 0; &lt;br /&gt;
  }   &lt;br /&gt;
  public TwoDimension(int i, int j) { &lt;br /&gt;
     x = i; &lt;br /&gt;
     y = j;&lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  // Overload true.   &lt;br /&gt;
  public static bool operator true(TwoDimension op) { &lt;br /&gt;
    if((op.x != 0) || (op.y != 0)) &lt;br /&gt;
      return true; // at least one coordinate is non-zero &lt;br /&gt;
    else &lt;br /&gt;
      return false; &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  // Overload false. &lt;br /&gt;
  public static bool operator false(TwoDimension op) { &lt;br /&gt;
    if((op.x == 0) &amp;amp;&amp;amp; (op.y == 0)) &lt;br /&gt;
      return true; // all coordinates are zero &lt;br /&gt;
    else &lt;br /&gt;
      return false; &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  // Overload unary --.  &lt;br /&gt;
  public static TwoDimension operator --(TwoDimension op)  &lt;br /&gt;
  {  &lt;br /&gt;
    // for ++, modify argument  &lt;br /&gt;
    op.x--;  &lt;br /&gt;
    op.y--;   &lt;br /&gt;
  &lt;br /&gt;
    return op;  &lt;br /&gt;
  }  &lt;br /&gt;
 &lt;br /&gt;
  // Show X, Y, Z coordinates.   &lt;br /&gt;
  public void show()   &lt;br /&gt;
  {   &lt;br /&gt;
    Console.WriteLine(x + &amp;quot;, &amp;quot; + y);   &lt;br /&gt;
  }   &lt;br /&gt;
}   &lt;br /&gt;
   &lt;br /&gt;
class MainClass {   &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    TwoDimension a = new TwoDimension(5, 6);   &lt;br /&gt;
    TwoDimension b = new TwoDimension(10, 10);   &lt;br /&gt;
    TwoDimension c = new TwoDimension(0, 0);   &lt;br /&gt;
   &lt;br /&gt;
    Console.Write(&amp;quot;Here is a: &amp;quot;);   &lt;br /&gt;
    a.show();   &lt;br /&gt;
    Console.Write(&amp;quot;Here is b: &amp;quot;);   &lt;br /&gt;
    b.show();   &lt;br /&gt;
    Console.Write(&amp;quot;Here is c: &amp;quot;);   &lt;br /&gt;
    c.show();   &lt;br /&gt;
    Console.WriteLine();   &lt;br /&gt;
   &lt;br /&gt;
    if(a) &lt;br /&gt;
       Console.WriteLine(&amp;quot;a is true.&amp;quot;); &lt;br /&gt;
    else &lt;br /&gt;
       Console.WriteLine(&amp;quot;a is false.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    if(b) &lt;br /&gt;
       Console.WriteLine(&amp;quot;b is true.&amp;quot;); &lt;br /&gt;
    else &lt;br /&gt;
       Console.WriteLine(&amp;quot;b is false.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    if(c) &lt;br /&gt;
       Console.WriteLine(&amp;quot;c is true.&amp;quot;); &lt;br /&gt;
    else &lt;br /&gt;
       Console.WriteLine(&amp;quot;c is false.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Control a loop using a TwoDimension object.&amp;quot;); &lt;br /&gt;
    do { &lt;br /&gt;
      b.show(); &lt;br /&gt;
      b--; &lt;br /&gt;
    } while(b); &lt;br /&gt;
 &lt;br /&gt;
  }   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Here is a: 5, 6&lt;br /&gt;
Here is b: 10, 10&lt;br /&gt;
Here is c: 0, 0&lt;br /&gt;
a is true.&lt;br /&gt;
b is true.&lt;br /&gt;
c is false.&lt;br /&gt;
Control a loop using a TwoDimension object.&lt;br /&gt;
10, 10&lt;br /&gt;
9, 9&lt;br /&gt;
8, 8&lt;br /&gt;
7, 7&lt;br /&gt;
6, 6&lt;br /&gt;
5, 5&lt;br /&gt;
4, 4&lt;br /&gt;
3, 3&lt;br /&gt;
2, 2&lt;br /&gt;
1, 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==true and false operator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
    public class MyType&lt;br /&gt;
    {&lt;br /&gt;
        public static bool operator true ( MyType e )&lt;br /&gt;
        {&lt;br /&gt;
            return  ( e == null ) ? false : e.b;&lt;br /&gt;
        }&lt;br /&gt;
        public static bool operator false ( MyType e )&lt;br /&gt;
        {&lt;br /&gt;
            return  ( e == null ) ? true : !e.b;&lt;br /&gt;
        }&lt;br /&gt;
        public bool b;&lt;br /&gt;
        public MyType( bool b )&lt;br /&gt;
        {&lt;br /&gt;
            this.b = b;&lt;br /&gt;
        }&lt;br /&gt;
        public static void Main( string[] args )&lt;br /&gt;
        {&lt;br /&gt;
            MyType myTrue = new MyType( true );&lt;br /&gt;
            MyType myFalse = new MyType( false );&lt;br /&gt;
            MyType myNull = null;&lt;br /&gt;
            if ( myTrue )&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;true&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;false&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            if ( myFalse )&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;true&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;false&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            if ( myNull )&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;true&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                System.Console.WriteLine( &amp;quot;false&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;true&lt;br /&gt;
false&lt;br /&gt;
false&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==true/false operator for Complex==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
public struct Complex&lt;br /&gt;
{&lt;br /&gt;
    public Complex( double real, double imaginary ) {&lt;br /&gt;
        this.real = real;&lt;br /&gt;
        this.imaginary = imaginary;&lt;br /&gt;
    }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format( &amp;quot;({0}, {1})&amp;quot;, real, imaginary );&lt;br /&gt;
    }&lt;br /&gt;
    public double Magnitude {&lt;br /&gt;
        get {&lt;br /&gt;
            return Math.Sqrt( Math.Pow(this.real, 2) + Math.Pow(this.imaginary, 2) );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public static bool operator true( Complex c ) {&lt;br /&gt;
        return (c.real != 0) || (c.imaginary != 0);&lt;br /&gt;
    }&lt;br /&gt;
    public static bool operator false( Complex c ) {&lt;br /&gt;
        return (c.real == 0) &amp;amp;&amp;amp; (c.imaginary == 0);&lt;br /&gt;
    }&lt;br /&gt;
    private double real;&lt;br /&gt;
    private double imaginary;&lt;br /&gt;
}&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Complex cpx1 = new Complex( 1.0, 3.0 );&lt;br /&gt;
        if( cpx1 ) {&lt;br /&gt;
            Console.WriteLine( &amp;quot;cpx1 is true&amp;quot; );&lt;br /&gt;
        } else {&lt;br /&gt;
            Console.WriteLine( &amp;quot;cpx1 is false&amp;quot; );&lt;br /&gt;
        }&lt;br /&gt;
        Complex cpx2 = new Complex( 0, 0 );&lt;br /&gt;
        Console.WriteLine( &amp;quot;cpx2 is {0}&amp;quot;, cpx2 ? &amp;quot;true&amp;quot; : &amp;quot;false&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;cpx1 is true&lt;br /&gt;
cpx2 is false&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>