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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator/is&amp;diff=5792&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/is&amp;diff=5792&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/is&amp;diff=5793&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/is&amp;diff=5793&amp;oldid=prev"/>
				<updated>2010-05-26T12:17:26Z</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;==&amp;quot;is&amp;quot; operator for value data type: int, long and float==&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 myInt = 0;&lt;br /&gt;
    bool compatible = myInt is int;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myInt is int = &amp;quot; + compatible);&lt;br /&gt;
    compatible = myInt is long;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myInt is long = &amp;quot; + compatible);&lt;br /&gt;
    compatible = myInt is float;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myInt is float = &amp;quot; + compatible);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;myInt is int = True&lt;br /&gt;
myInt is long = False&lt;br /&gt;
myInt is float = False&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==is operator in class hiearchy==&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 A {} &lt;br /&gt;
class B : A {} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    A a = new A(); &lt;br /&gt;
    B b = new B(); &lt;br /&gt;
 &lt;br /&gt;
    if(a is A) &lt;br /&gt;
       Console.WriteLine(&amp;quot;a is an A&amp;quot;); &lt;br /&gt;
    if(b is A)  &lt;br /&gt;
      Console.WriteLine(&amp;quot;b is an A because it is derived from A&amp;quot;); &lt;br /&gt;
    if(a is B)  &lt;br /&gt;
      Console.WriteLine(&amp;quot;This won&amp;quot;t display -- a not derived from B&amp;quot;); &lt;br /&gt;
    if(b is B) &lt;br /&gt;
      Console.WriteLine(&amp;quot;B is a B&amp;quot;); &lt;br /&gt;
    if(a is object) &lt;br /&gt;
      Console.WriteLine(&amp;quot;a is an object&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 an A&lt;br /&gt;
b is an A because it is derived from A&lt;br /&gt;
B is a B&lt;br /&gt;
a is an object&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test if someObject is, or is derived from, a TextReader using the is 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;
using System.IO;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        Object someObject = new StringReader(&amp;quot;This is a StringReader&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        if (someObject is TextReader) &lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&lt;br /&gt;
                &amp;quot;is: someObject is a TextReader or a derived class&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;is: someObject is a TextReader or a derived class&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Type operators: Is==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Testing a Type with &amp;quot;is&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can determine whether an object is of a certain type by using the &amp;quot;is&amp;quot; operator.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Its general 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;expr is type&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use is in Console.WriteLine==&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 MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        String derivedObj = &amp;quot;Dummy&amp;quot;;&lt;br /&gt;
        Object baseObj1 = new Object();&lt;br /&gt;
        Object baseObj2 = derivedObj;&lt;br /&gt;
        Console.WriteLine( &amp;quot;baseObj2 {0} String&amp;quot;, baseObj2 is String ? &amp;quot;is&amp;quot; : &amp;quot;isnot&amp;quot; );&lt;br /&gt;
        Console.WriteLine( &amp;quot;baseObj1 {0} String&amp;quot;, baseObj1 is String ? &amp;quot;is&amp;quot; : &amp;quot;isnot&amp;quot; );&lt;br /&gt;
        Console.WriteLine( &amp;quot;derivedObj {0} Object&amp;quot;, derivedObj is Object ? &amp;quot;is&amp;quot; : &amp;quot;isnot&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;baseObj2 is String&lt;br /&gt;
baseObj1 isnot String&lt;br /&gt;
derivedObj is Object&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use &amp;quot;is&amp;quot; to avoid an invalid cast.==&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 A {} &lt;br /&gt;
class B : A {} &lt;br /&gt;
 &lt;br /&gt;
class CheckCast { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    A a = new A(); &lt;br /&gt;
    B b = new B(); &lt;br /&gt;
 &lt;br /&gt;
    if(a is B)&lt;br /&gt;
      b = (B) a; &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Working with Interfaces: is 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;
interface Printable&lt;br /&gt;
{&lt;br /&gt;
    void MarginX(float factor);&lt;br /&gt;
    void MarginY(float factor);&lt;br /&gt;
}&lt;br /&gt;
public class Component&lt;br /&gt;
{&lt;br /&gt;
    public Component() {}&lt;br /&gt;
}&lt;br /&gt;
public class TextField: Component, Printable&lt;br /&gt;
{&lt;br /&gt;
    public TextField(string text)&lt;br /&gt;
    {&lt;br /&gt;
        this.text = text;&lt;br /&gt;
    }&lt;br /&gt;
    // implementing Printable.MarginX()&lt;br /&gt;
    public void MarginX(float factor)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;MarginX: {0} {1}&amp;quot;, text, factor);&lt;br /&gt;
        // scale the object here.&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // implementing Printable.MarginY()&lt;br /&gt;
    public void MarginY(float factor)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;MarginY: {0} {1}&amp;quot;, text, factor);&lt;br /&gt;
        // scale the object here.&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private string text;&lt;br /&gt;
}&lt;br /&gt;
class Test&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Component[] dArray = new Component[100];&lt;br /&gt;
        &lt;br /&gt;
        dArray[0] = new Component();&lt;br /&gt;
        dArray[1] = new TextField(&amp;quot;A&amp;quot;);&lt;br /&gt;
        dArray[2] = new TextField(&amp;quot;B&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        foreach (Component d in dArray)&lt;br /&gt;
        {&lt;br /&gt;
            if (d is Printable)&lt;br /&gt;
            {&lt;br /&gt;
                Printable scalable = (Printable) d;&lt;br /&gt;
                scalable.MarginX(0.1F);&lt;br /&gt;
                scalable.MarginY(10.0F);&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;MarginX: A 0.1&lt;br /&gt;
MarginY: A 10&lt;br /&gt;
MarginX: B 0.1&lt;br /&gt;
MarginY: B 10&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>