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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Object_Reference&amp;diff=5613&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/Class/Object_Reference&amp;diff=5613&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/Class/Object_Reference&amp;diff=5614&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Object_Reference&amp;diff=5614&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:02Z</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;==Assign values to the House object&amp;quot;s fields using object renerence==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
    myHouse.make = &amp;quot;ABC&amp;quot;;&lt;br /&gt;
    myHouse.model = &amp;quot;Apartment&amp;quot;;&lt;br /&gt;
    myHouse.color = &amp;quot;black&amp;quot;;&lt;br /&gt;
    myHouse.yearBuilt = 1995;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Change the object referenced by the myHouse object reference to the object referenced by yourHouse==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
    myHouse.Start();&lt;br /&gt;
    myHouse.Stop();&lt;br /&gt;
    &lt;br /&gt;
    House yourHouse = new House();&lt;br /&gt;
    yourHouse.make = &amp;quot;AAA&amp;quot;;&lt;br /&gt;
    yourHouse.model = &amp;quot;VVV&amp;quot;;&lt;br /&gt;
    yourHouse.color = &amp;quot;red&amp;quot;;&lt;br /&gt;
    yourHouse.yearBuilt = 2000;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;yourHouse is a &amp;quot; + yourHouse.model);&lt;br /&gt;
    &lt;br /&gt;
    System.Console.WriteLine(&amp;quot;Assigning yourHouse to myHouse&amp;quot;);&lt;br /&gt;
    myHouse = yourHouse;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse details:&amp;quot;);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.make = &amp;quot; + myHouse.make);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.model = &amp;quot; + myHouse.model);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.color = &amp;quot; + myHouse.color);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.yearBuilt = &amp;quot; + myHouse.yearBuilt);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;started&lt;br /&gt;
 stopped&lt;br /&gt;
yourHouse is a VVV&lt;br /&gt;
Assigning yourHouse to myHouse&lt;br /&gt;
myHouse details:&lt;br /&gt;
myHouse.make = AAA&lt;br /&gt;
myHouse.model = VVV&lt;br /&gt;
myHouse.color = red&lt;br /&gt;
myHouse.yearBuilt = 2000&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Class comparison==&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 ComparingRelations&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {   &lt;br /&gt;
            int a = 12;&lt;br /&gt;
            int b = 12;&lt;br /&gt;
            Console.WriteLine( a == b );&lt;br /&gt;
            Console.WriteLine( (object)a == (object)b );&lt;br /&gt;
&lt;br /&gt;
            string c = &amp;quot;hello&amp;quot;;&lt;br /&gt;
            string d = &amp;quot;hello&amp;quot;;&lt;br /&gt;
            Console.WriteLine( (object) c==(object) d );&lt;br /&gt;
            ClassCompare x = new ClassCompare();&lt;br /&gt;
            ClassCompare y;&lt;br /&gt;
            x.val = 1;&lt;br /&gt;
            y = x;&lt;br /&gt;
            Console.WriteLine( x == y );&lt;br /&gt;
            x.val = 2;&lt;br /&gt;
            Console.WriteLine( y.val.ToString() );&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
    class ClassCompare&lt;br /&gt;
    {&lt;br /&gt;
        public int val = 0;&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Creating a House object and assigning its memory location to myHouse==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare a House object reference named myHouse==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;Creating a House object and assigning its memory location to myHouse&amp;quot;);&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Creating a House object and assigning its memory location to myHouse&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare another House object reference and create another House object==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
    myHouse.Start();&lt;br /&gt;
    myHouse.Stop();&lt;br /&gt;
    &lt;br /&gt;
    House yourHouse = new House();&lt;br /&gt;
    yourHouse.make = &amp;quot;AQW&amp;quot;;&lt;br /&gt;
    yourHouse.model = &amp;quot;SSS&amp;quot;;&lt;br /&gt;
    yourHouse.color = &amp;quot;red&amp;quot;;&lt;br /&gt;
    yourHouse.yearBuilt = 2000;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;yourHouse is a &amp;quot; + yourHouse.model);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;started&lt;br /&gt;
 stopped&lt;br /&gt;
yourHouse is a SSS&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare class fields and methods==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;The new operator dynamically allocates memory for an object and returns a reference to it.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;This reference is, more or less, the address in memory of the object allocated by new.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;This reference is then stored in a variable.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;Creating a House object and assigning its memory location to myHouse&amp;quot;);&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Creating a House object and assigning its memory location to myHouse&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Display the field values using object reference==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class House&lt;br /&gt;
{&lt;br /&gt;
  public string make;&lt;br /&gt;
  public string model;&lt;br /&gt;
  public string color;&lt;br /&gt;
  public int yearBuilt;&lt;br /&gt;
  public void Start()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void Stop()&lt;br /&gt;
  {&lt;br /&gt;
    System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    &lt;br /&gt;
    House myHouse;&lt;br /&gt;
    myHouse = new House();&lt;br /&gt;
    myHouse.make = &amp;quot;ABC&amp;quot;;&lt;br /&gt;
    myHouse.model = &amp;quot;Apartment&amp;quot;;&lt;br /&gt;
    myHouse.color = &amp;quot;black&amp;quot;;&lt;br /&gt;
    myHouse.yearBuilt = 1995;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse details:&amp;quot;);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.make = &amp;quot; + myHouse.make);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.model = &amp;quot; + myHouse.model);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.color = &amp;quot; + myHouse.color);&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myHouse.yearBuilt = &amp;quot; + myHouse.yearBuilt);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;myHouse details:&lt;br /&gt;
myHouse.make = ABC&lt;br /&gt;
myHouse.model = Apartment&lt;br /&gt;
myHouse.color = black&lt;br /&gt;
myHouse.yearBuilt = 1995&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass reference type variable without &amp;quot;out&amp;quot; and &amp;quot;ref&amp;quot;==&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 MyClass&lt;br /&gt;
{&lt;br /&gt;
   public int Val = 20;&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void MyMethod(MyClass myObject, int intValue)&lt;br /&gt;
   {&lt;br /&gt;
      myObject.Val = myObject.Val + 5;&lt;br /&gt;
      intValue = intValue + 5;        &lt;br /&gt;
   }&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass myObject = new MyClass();&lt;br /&gt;
      int intValue = 10;&lt;br /&gt;
      Console.WriteLine(&amp;quot;Before -- myObject.Val: {0}, intValue: {1}&amp;quot;, myObject.Val, intValue);&lt;br /&gt;
      MyMethod(myObject, intValue);&lt;br /&gt;
      Console.WriteLine(&amp;quot;After  -- myObject.Val: {0}, intValue: {1}&amp;quot;, myObject.Val, intValue);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Before -- myObject.Val: 20, intValue: 10&lt;br /&gt;
After  -- myObject.Val: 25, intValue: 10&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference an object by interface and class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;You can create an interface reference variable.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Such a variable can refer to any object that implements its interface.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;When you call a method on an object through an interface reference, the method is the version of the method implemented by the object.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public interface Player&lt;br /&gt;
{&lt;br /&gt;
 void PlayMusic();&lt;br /&gt;
}&lt;br /&gt;
public class Student : Player&lt;br /&gt;
{&lt;br /&gt;
 public void PlayMusic(){}&lt;br /&gt;
 public void DoALittleDance(){}&lt;br /&gt;
}&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      Student st = new Student();&lt;br /&gt;
      Player musician = st;&lt;br /&gt;
      musician.PlayMusic();&lt;br /&gt;
      st.PlayMusic();&lt;br /&gt;
      st.DoALittleDance();&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference a static member function without using the class name==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class A&lt;br /&gt;
{&lt;br /&gt;
   public static void SomeFunction()&lt;br /&gt;
   {&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;SomeFunction() called&amp;quot; );&lt;br /&gt;
   }&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      A.SomeFunction();&lt;br /&gt;
      SomeFunction();&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;SomeFunction() called&lt;br /&gt;
SomeFunction() called&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference equals==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class MyClass&lt;br /&gt;
{&lt;br /&gt;
   public MyClass(  )&lt;br /&gt;
   {&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
}&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass referenceA = new MyClass(  );&lt;br /&gt;
      MyClass referenceB = new MyClass(  );&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;Result of Equality is {0}&amp;quot;, referenceA == referenceB );&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Result of Equality is False&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference one object by multiple interfaces==&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 Interface1 {&lt;br /&gt;
      void PrintOut(string s);&lt;br /&gt;
}&lt;br /&gt;
interface Interface2 {&lt;br /&gt;
      void PrintOut(string s);&lt;br /&gt;
}&lt;br /&gt;
class MyClass : Interface1, Interface2&lt;br /&gt;
{&lt;br /&gt;
   public void PrintOut(string s)&lt;br /&gt;
   {&lt;br /&gt;
      Console.WriteLine(s);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass mc = new MyClass();&lt;br /&gt;
      Interface1 ifc1 = (Interface1)mc;&lt;br /&gt;
      Interface2 ifc2 = (Interface2)mc;&lt;br /&gt;
      mc.PrintOut(&amp;quot;object.&amp;quot;);&lt;br /&gt;
      ifc1.PrintOut(&amp;quot;interface 1.&amp;quot;);&lt;br /&gt;
      ifc2.PrintOut(&amp;quot;interface 2.&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;object.&lt;br /&gt;
interface 1.&lt;br /&gt;
interface 2.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference type equals: complex number==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class ComplexNumber&lt;br /&gt;
{&lt;br /&gt;
   public ComplexNumber( int real, int imaginary )&lt;br /&gt;
   {&lt;br /&gt;
      this.real = real;&lt;br /&gt;
      this.imaginary = imaginary;&lt;br /&gt;
   }&lt;br /&gt;
   public override bool Equals( object obj )&lt;br /&gt;
   {&lt;br /&gt;
      ComplexNumber other = obj as ComplexNumber;&lt;br /&gt;
      if( other == null )&lt;br /&gt;
      {&lt;br /&gt;
         return false;&lt;br /&gt;
      }&lt;br /&gt;
      return (this.real == other.real) &amp;amp;&amp;amp; (this.imaginary == other.imaginary);&lt;br /&gt;
   }&lt;br /&gt;
   public override int GetHashCode()&lt;br /&gt;
   {&lt;br /&gt;
      return (int) real ^ (int) imaginary;&lt;br /&gt;
   }&lt;br /&gt;
   public static bool operator==( ComplexNumber me, ComplexNumber other )&lt;br /&gt;
   {&lt;br /&gt;
      return Equals( me, other );&lt;br /&gt;
   }&lt;br /&gt;
   public static bool operator!=( ComplexNumber me, ComplexNumber other )&lt;br /&gt;
   {&lt;br /&gt;
      return Equals( me, other );&lt;br /&gt;
   }&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;
   {&lt;br /&gt;
      ComplexNumber referenceA = new ComplexNumber( 1, 2 );&lt;br /&gt;
      ComplexNumber referenceB = new ComplexNumber( 1, 2 );&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;Result of Equality is {0}&amp;quot;,referenceA == referenceB );&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;Identity of references is {0}&amp;quot;,(object) referenceA == (object) referenceB );&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;Identity of references is {0}&amp;quot;,ReferenceEquals(referenceA, referenceB) );&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Result of Equality is True&lt;br /&gt;
Identity of references is False&lt;br /&gt;
Identity of references is False&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use interface as reference==&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 Interface1&lt;br /&gt;
{&lt;br /&gt;
   void PrintOut(string s);&lt;br /&gt;
}&lt;br /&gt;
class MyClass : Interface1&lt;br /&gt;
{&lt;br /&gt;
   public void PrintOut(string s)&lt;br /&gt;
   {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Calling through: {0}&amp;quot;, s);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass mc = new MyClass();         &lt;br /&gt;
      mc.PrintOut(&amp;quot;object.&amp;quot;);             &lt;br /&gt;
      Interface1 ifc = (Interface1)mc;    &lt;br /&gt;
      ifc.PrintOut(&amp;quot;interface.&amp;quot;);         &lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Calling through: object.&lt;br /&gt;
Calling through: interface.&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>