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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Explicit_Interface_Implementation&amp;diff=5669&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/Explicit_Interface_Implementation&amp;diff=5669&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/Explicit_Interface_Implementation&amp;diff=5670&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/Explicit_Interface_Implementation&amp;diff=5670&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:09Z</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;==Explicit Interface Implementation==&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 InterfaceOne&lt;br /&gt;
{&lt;br /&gt;
    void Execute();&lt;br /&gt;
}&lt;br /&gt;
interface InterfaceTwo&lt;br /&gt;
{&lt;br /&gt;
    void Execute();&lt;br /&gt;
}&lt;br /&gt;
class MyImplementation: InterfaceOne, InterfaceTwo&lt;br /&gt;
{&lt;br /&gt;
    void InterfaceOne.Execute() &lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;InterfaceOne.Execute implementation&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    void InterfaceTwo.Execute()&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;InterfaceTwo.Execute implementation&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;
        MyImplementation MyImplementation = new MyImplementation();&lt;br /&gt;
        &lt;br /&gt;
        InterfaceOne InterfaceOne = (InterfaceOne) MyImplementation;&lt;br /&gt;
        InterfaceOne.Execute();&lt;br /&gt;
        &lt;br /&gt;
        InterfaceTwo InterfaceTwo = (InterfaceTwo) MyImplementation;&lt;br /&gt;
        InterfaceTwo.Execute();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;InterfaceOne.Execute implementation&lt;br /&gt;
InterfaceTwo.Execute implementation&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explicit interface implementation and its own implementation==&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 InterfaceOne&lt;br /&gt;
{&lt;br /&gt;
    void Execute();&lt;br /&gt;
}&lt;br /&gt;
interface InterfaceTwo&lt;br /&gt;
{&lt;br /&gt;
    void Execute();&lt;br /&gt;
}&lt;br /&gt;
class MyImplementation: InterfaceOne, InterfaceTwo&lt;br /&gt;
{&lt;br /&gt;
    void InterfaceOne.Execute() &lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;InterfaceOne.Execute implementation&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    void InterfaceTwo.Execute()&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;InterfaceTwo.Execute implementation&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void Execute()&lt;br /&gt;
    {&lt;br /&gt;
        ((InterfaceOne) this).Execute();&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;
        MyImplementation MyImplementation = new MyImplementation();&lt;br /&gt;
        &lt;br /&gt;
        MyImplementation.Execute();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;InterfaceOne.Execute implementation&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explicitly implement an interface member==&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;
interface MyInterface { &lt;br /&gt;
  bool MyMethodA(int x); &lt;br /&gt;
  bool MyMethodB(int x); &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MyClass : MyInterface { &lt;br /&gt;
 &lt;br /&gt;
  // Explicit implementation. &lt;br /&gt;
  bool MyInterface.MyMethodA(int x) { &lt;br /&gt;
    if((x%2) != 0) &lt;br /&gt;
       return true; &lt;br /&gt;
    else &lt;br /&gt;
       return false; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Normal implementation. &lt;br /&gt;
  public bool MyMethodB(int x) { &lt;br /&gt;
    MyInterface o = this; // reference to invoking object &lt;br /&gt;
 &lt;br /&gt;
    return !o.MyMethodA(x); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    MyClass ob = new MyClass(); &lt;br /&gt;
    bool result; &lt;br /&gt;
 &lt;br /&gt;
    result = ob.MyMethodB(4); &lt;br /&gt;
    if(result) Console.WriteLine(&amp;quot;4 is even.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    // result = ob.MyMethodA(4); // Error, MyMethodA not directly accessible &lt;br /&gt;
 &lt;br /&gt;
    MyInterface iRef = (MyInterface) ob; &lt;br /&gt;
    result = iRef.MyMethodA(3); &lt;br /&gt;
    if(result) Console.WriteLine(&amp;quot;3 is odd.&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;4 is even.&lt;br /&gt;
3 is odd.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Interface member hiding==&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;
public interface InterfaceA&lt;br /&gt;
{&lt;br /&gt;
  void MethodA();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface InterfaceB : InterfaceA&lt;br /&gt;
{&lt;br /&gt;
  new void MethodA();  // hides MethodA() in InterfaceA&lt;br /&gt;
}&lt;br /&gt;
public class MyClass : InterfaceB&lt;br /&gt;
{&lt;br /&gt;
  void InterfaceB.MethodA()&lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(&amp;quot;InterfaceB implementation of MethodA()&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void MethodA()&lt;br /&gt;
  {&lt;br /&gt;
    Console.WriteLine(&amp;quot;InterfaceA implementation of MethodA()&amp;quot;);&lt;br /&gt;
  }&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;
    MyClass myClass = new MyClass();&lt;br /&gt;
    Console.WriteLine(&amp;quot;Calling myClass.MethodA()&amp;quot;);&lt;br /&gt;
    myClass.MethodA();&lt;br /&gt;
    InterfaceB mySteerable = myClass as InterfaceB;&lt;br /&gt;
    Console.WriteLine(&amp;quot;Calling mySteerable.MethodA()&amp;quot;);&lt;br /&gt;
    mySteerable.MethodA();&lt;br /&gt;
    InterfaceA myDrivable = myClass as InterfaceA;&lt;br /&gt;
    Console.WriteLine(&amp;quot;Calling myDrivable.MethodA()&amp;quot;);&lt;br /&gt;
    myDrivable.MethodA();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Calling myClass.MethodA()&lt;br /&gt;
InterfaceA implementation of MethodA()&lt;br /&gt;
Calling mySteerable.MethodA()&lt;br /&gt;
InterfaceB implementation of MethodA()&lt;br /&gt;
Calling myDrivable.MethodA()&lt;br /&gt;
InterfaceA implementation of MethodA()&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use explicit implementation to remove ambiguity==&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;
interface MyInterfaceA { &lt;br /&gt;
  int Method(int x); &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
interface MyInterfaceB { &lt;br /&gt;
  int Method(int x); &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// MyClass implements both interfaces. &lt;br /&gt;
class MyClass : MyInterfaceA, MyInterfaceB { &lt;br /&gt;
 &lt;br /&gt;
  // explicitly implement the two Method()s &lt;br /&gt;
  int MyInterfaceA.Method(int x) { &lt;br /&gt;
    return x + x; &lt;br /&gt;
  } &lt;br /&gt;
  int MyInterfaceB.Method(int x) { &lt;br /&gt;
    return x * x; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // call Method() through an interface reference. &lt;br /&gt;
  public int MethodA(int x){ &lt;br /&gt;
    MyInterfaceA a_ob; &lt;br /&gt;
    a_ob = this; &lt;br /&gt;
    return a_ob.Method(x); // calls MyInterfaceA &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public int MethodB(int x){ &lt;br /&gt;
    MyInterfaceB b_ob; &lt;br /&gt;
    b_ob = this; &lt;br /&gt;
    return b_ob.Method(x); // calls MyInterfaceB &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    MyClass ob = new MyClass(); &lt;br /&gt;
 &lt;br /&gt;
    Console.Write(&amp;quot;Calling MyInterfaceA.Method(): &amp;quot;); &lt;br /&gt;
    Console.WriteLine(ob.MethodA(3)); &lt;br /&gt;
 &lt;br /&gt;
    Console.Write(&amp;quot;Calling MyInterfaceB.Method(): &amp;quot;); &lt;br /&gt;
    Console.WriteLine(ob.MethodB(3)); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Calling MyInterfaceA.Method(): 6&lt;br /&gt;
Calling MyInterfaceB.Method(): 9&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>