<?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%2FShort_Circuit_Operators</id>
		<title>Csharp/CSharp Tutorial/Operator/Short Circuit Operators - История изменений</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%2FShort_Circuit_Operators"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator/Short_Circuit_Operators&amp;action=history"/>
		<updated>2026-04-29T19:35:10Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator/Short_Circuit_Operators&amp;diff=5796&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/Short_Circuit_Operators&amp;diff=5796&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/Short_Circuit_Operators&amp;diff=5797&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/Short_Circuit_Operators&amp;diff=5797&amp;oldid=prev"/>
				<updated>2010-05-26T12:17:27Z</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;==Side-effects of short-circuit operators==&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 Example {    &lt;br /&gt;
  public static void Main() {    &lt;br /&gt;
    int i; &lt;br /&gt;
    bool someCondition = false; &lt;br /&gt;
 &lt;br /&gt;
    i = 0; &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;i is still incremented even though the if statement fails.&amp;quot;); &lt;br /&gt;
    if(someCondition &amp;amp; (++i &amp;lt; 100)) &lt;br /&gt;
       Console.WriteLine(&amp;quot;this won&amp;quot;t be displayed&amp;quot;); &lt;br /&gt;
    Console.WriteLine(&amp;quot;if statement executed: &amp;quot; + i); // displays 1 &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;i is not incremented because the short-circuit operator skips the increment.&amp;quot;);&lt;br /&gt;
    if(someCondition &amp;amp;&amp;amp; (++i &amp;lt; 100)) &lt;br /&gt;
      Console.WriteLine(&amp;quot;this won&amp;quot;t be displayed&amp;quot;); &lt;br /&gt;
    &lt;br /&gt;
    Console.WriteLine(&amp;quot;if statement executed: &amp;quot; + i); // still 1 !! &lt;br /&gt;
  }    &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;i is still incremented even though the if statement fails.&lt;br /&gt;
if statement executed: 1&lt;br /&gt;
i is not incremented because the short-circuit operator skips the increment.&lt;br /&gt;
if statement executed: 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The short-circuit operators==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The short-circuit AND operator is &amp;amp;&amp;amp; and the short-circuit OR operator is ||.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;As described earlier, their normal counterparts are &amp;amp; and |.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The normal operands will always evaluate each operand, but short-circuit versions will evaluate the second operand only when necessary.&amp;lt;/p&amp;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 Example {    &lt;br /&gt;
  public static void Main() {    &lt;br /&gt;
    int n, d; &lt;br /&gt;
 &lt;br /&gt;
    n = 10; &lt;br /&gt;
    d = 2; &lt;br /&gt;
    if(d != 0 &amp;amp;&amp;amp; (n % d) == 0) &lt;br /&gt;
      Console.WriteLine(d + &amp;quot; is a factor of &amp;quot; + n); &lt;br /&gt;
 &lt;br /&gt;
    d = 0; // now, set d to zero &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Since d is zero, the second operand is not evaluated.&amp;quot;); &lt;br /&gt;
    if(d != 0 &amp;amp;&amp;amp; (n % d) == 0) &lt;br /&gt;
      Console.WriteLine(d + &amp;quot; is a factor of &amp;quot; + n);  &lt;br /&gt;
     &lt;br /&gt;
    Console.WriteLine(&amp;quot;try the same thing without short-circuit operator. This will cause a divide-by-zero error.&amp;quot;);&lt;br /&gt;
    if(d != 0 &amp;amp; (n % d) == 0) &lt;br /&gt;
       Console.WriteLine(d + &amp;quot; is a factor of &amp;quot; + n); &lt;br /&gt;
  }    &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;2 is a factor of 10&lt;br /&gt;
Since d is zero, the second operand is not evaluated.&lt;br /&gt;
try the same thing without short-circuit operator. This will cause a divide-by-zero error.&lt;br /&gt;
Unhandled Exception: System.DivideByZeroException: Attempted to divide by zero.&lt;br /&gt;
   at Example.Main()&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>