<?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%2FStatement%2FIf</id>
		<title>Csharp/CSharp Tutorial/Statement/If - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FStatement%2FIf"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Statement/If&amp;action=history"/>
		<updated>2026-04-30T00:11:39Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Statement/If&amp;diff=6614&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/Statement/If&amp;diff=6614&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/Statement/If&amp;diff=6615&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Statement/If&amp;diff=6615&amp;oldid=prev"/>
				<updated>2010-05-26T12:20:03Z</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;==A nested if statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    int intValue = 1500;&lt;br /&gt;
    string stringValue = &amp;quot; &amp;quot;;&lt;br /&gt;
    if (intValue &amp;lt; 1000)&lt;br /&gt;
    {&lt;br /&gt;
      System.Console.WriteLine(&amp;quot;intValue &amp;lt; 1000&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      System.Console.WriteLine(&amp;quot;intValue &amp;gt;= 1000&amp;quot;);&lt;br /&gt;
      if (stringValue == &amp;quot;closed&amp;quot;)&lt;br /&gt;
      {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;closed&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;intValue &amp;gt;= 1000&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==bool values in if statement==&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;
    bool b; &lt;br /&gt;
 &lt;br /&gt;
    b = false; &lt;br /&gt;
    Console.WriteLine(&amp;quot;b is &amp;quot; + b); &lt;br /&gt;
    b = true; &lt;br /&gt;
    Console.WriteLine(&amp;quot;b is &amp;quot; + b); &lt;br /&gt;
 &lt;br /&gt;
    // a bool value can control the if statement &lt;br /&gt;
    if(b) &lt;br /&gt;
       Console.WriteLine(&amp;quot;This is executed.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    b = false; &lt;br /&gt;
    if(b) &lt;br /&gt;
       Console.WriteLine(&amp;quot;This is not executed.&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;b is False&lt;br /&gt;
b is True&lt;br /&gt;
This is executed.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Demonstrate the if statement==&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 MainClass {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int a, b, c;  &lt;br /&gt;
  &lt;br /&gt;
    a = 2;  &lt;br /&gt;
    b = 3;  &lt;br /&gt;
  &lt;br /&gt;
    if(a &amp;lt; b) &lt;br /&gt;
        Console.WriteLine(&amp;quot;a is less than b&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    if(a == b) &lt;br /&gt;
        Console.WriteLine(&amp;quot;you won&amp;quot;t see this&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    c = a - b;&lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;c is&amp;quot;,c); &lt;br /&gt;
    if(c &amp;gt;= 0) &lt;br /&gt;
         Console.WriteLine(&amp;quot;c is non-negative&amp;quot;); &lt;br /&gt;
    if(c &amp;lt; 0) &lt;br /&gt;
         Console.WriteLine(&amp;quot;c is negative&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    c = b - a;&lt;br /&gt;
    Console.WriteLine(&amp;quot;c is&amp;quot;,c); &lt;br /&gt;
    if(c &amp;gt;= 0) &lt;br /&gt;
        Console.WriteLine(&amp;quot;c is non-negative&amp;quot;); &lt;br /&gt;
    if(c &amp;lt; 0) &lt;br /&gt;
        Console.WriteLine(&amp;quot;c is negative&amp;quot;); &lt;br /&gt;
  }  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;a is less than b&lt;br /&gt;
c is&lt;br /&gt;
c is negative&lt;br /&gt;
c is&lt;br /&gt;
c is non-negative&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine if a value is positive, negative, or zero==&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 MainClass {  &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    for(i=-5; i &amp;lt;= 5; i++) { &lt;br /&gt;
 &lt;br /&gt;
      Console.Write(&amp;quot;Testing &amp;quot; + i + &amp;quot;: &amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
      if(i &amp;lt; 0) &lt;br /&gt;
          Console.WriteLine(&amp;quot;negative&amp;quot;); &lt;br /&gt;
      else if(i == 0) &lt;br /&gt;
          Console.WriteLine(&amp;quot;no sign&amp;quot;); &lt;br /&gt;
      else &lt;br /&gt;
          Console.WriteLine(&amp;quot;positive&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;Testing -5: negative&lt;br /&gt;
Testing -4: negative&lt;br /&gt;
Testing -3: negative&lt;br /&gt;
Testing -2: negative&lt;br /&gt;
Testing -1: negative&lt;br /&gt;
Testing 0: no sign&lt;br /&gt;
Testing 1: positive&lt;br /&gt;
Testing 2: positive&lt;br /&gt;
Testing 3: positive&lt;br /&gt;
Testing 4: positive&lt;br /&gt;
Testing 5: positive&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==If a value is positive or negative==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The semicolon signals the end of a statement.&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 MainClass {  &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    for(i=-5; i &amp;lt;= 5; i++) { &lt;br /&gt;
      Console.Write(&amp;quot;Testing &amp;quot; + i + &amp;quot;: &amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
      if(i &amp;lt; 0) &lt;br /&gt;
         Console.WriteLine(&amp;quot;negative&amp;quot;); &lt;br /&gt;
      else &lt;br /&gt;
         Console.WriteLine(&amp;quot;positive&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;Testing -5: negative&lt;br /&gt;
Testing -4: negative&lt;br /&gt;
Testing -3: negative&lt;br /&gt;
Testing -2: negative&lt;br /&gt;
Testing -1: negative&lt;br /&gt;
Testing 0: positive&lt;br /&gt;
Testing 1: positive&lt;br /&gt;
Testing 2: positive&lt;br /&gt;
Testing 3: positive&lt;br /&gt;
Testing 4: positive&lt;br /&gt;
Testing 5: positive&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==if statement with || and &amp;amp;&amp;amp;==&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;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    int a = 5, b = 5, c = 10;&lt;br /&gt;
    if (a == b)&lt;br /&gt;
      Console.WriteLine(a);&lt;br /&gt;
    if ((a &amp;gt; c) || (a == b))&lt;br /&gt;
      Console.WriteLine(b);&lt;br /&gt;
    if ((a &amp;gt;= c) &amp;amp;&amp;amp; (b &amp;lt;= c))&lt;br /&gt;
      Console.WriteLine(c);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;5&lt;br /&gt;
5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Relational operators that can be used in a conditional expression.==&lt;br /&gt;
&lt;br /&gt;
Operator&lt;br /&gt;
Meaning&lt;br /&gt;
&amp;lt;&lt;br /&gt;
Less than&lt;br /&gt;
&amp;lt;=&lt;br /&gt;
Less than or equal&lt;br /&gt;
&amp;gt;&lt;br /&gt;
Greater than&lt;br /&gt;
&amp;gt;=&lt;br /&gt;
Greater than or equal&lt;br /&gt;
==&lt;br /&gt;
Equal to&lt;br /&gt;
!=&lt;br /&gt;
Not equal&lt;br /&gt;
&lt;br /&gt;
==The if Statement==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You can selectively execute part of a program through the if statement.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Its simplest form is shown here:&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;if(condition) &lt;br /&gt;
   statement;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use an if statement that executes a block==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;A code block is a grouping of two or more statements. &lt;br /&gt;
This is done by enclosing the statements between opening and closing curly braces.&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;class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    int smallNumber = 5;&lt;br /&gt;
    int bigNumber = 100;&lt;br /&gt;
    if (bigNumber &amp;lt; smallNumber)&lt;br /&gt;
    {&lt;br /&gt;
      System.Console.Write(bigNumber);&lt;br /&gt;
      System.Console.Write(&amp;quot; is less than &amp;quot;);&lt;br /&gt;
      System.Console.Write(smallNumber);&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      System.Console.Write(smallNumber);&lt;br /&gt;
      System.Console.Write(&amp;quot; is less than &amp;quot;);&lt;br /&gt;
      System.Console.Write(bigNumber);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;5 is less than 100&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>