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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Generic/Generic_Interface&amp;diff=5265&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/Generic/Generic_Interface&amp;diff=5265&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/Generic/Generic_Interface&amp;diff=5266&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Generic/Generic_Interface&amp;diff=5266&amp;oldid=prev"/>
				<updated>2010-05-26T12:14:45Z</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;==Declaring a Generic Interface, Implementing a Generic Interface==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;interface IPair&amp;lt;T&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    T First&lt;br /&gt;
    {&lt;br /&gt;
        get;&lt;br /&gt;
        set;&lt;br /&gt;
    }&lt;br /&gt;
    T Second&lt;br /&gt;
    {&lt;br /&gt;
        get;&lt;br /&gt;
        set;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public struct Pair&amp;lt;T&amp;gt;: IPair&amp;lt;T&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    public T First&lt;br /&gt;
    {&lt;br /&gt;
        get&lt;br /&gt;
        {&lt;br /&gt;
            return _First;&lt;br /&gt;
        }&lt;br /&gt;
        set&lt;br /&gt;
        {&lt;br /&gt;
            _First = value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private T _First;&lt;br /&gt;
    public T Second&lt;br /&gt;
    {&lt;br /&gt;
        get&lt;br /&gt;
        {&lt;br /&gt;
            return _Second;&lt;br /&gt;
        }&lt;br /&gt;
        set&lt;br /&gt;
        {&lt;br /&gt;
            _Second = value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private T _Second;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declaring a Generic with Multiple Type Parameters==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;interface IPair&amp;lt;TFirst, TSecond&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    TFirst First&lt;br /&gt;
    { get; set;    }&lt;br /&gt;
    TSecond Second&lt;br /&gt;
    { get; set;    }&lt;br /&gt;
}&lt;br /&gt;
public struct Pair&amp;lt;TFirst, TSecond&amp;gt;: IPair&amp;lt;TFirst, TSecond&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    public Pair(TFirst first, TSecond second)&lt;br /&gt;
    {&lt;br /&gt;
        _First = first;&lt;br /&gt;
        _Second = second;&lt;br /&gt;
    }&lt;br /&gt;
    public TFirst First&lt;br /&gt;
    {&lt;br /&gt;
        get{ return _First;    }&lt;br /&gt;
        set{ _First = value; }&lt;br /&gt;
    }&lt;br /&gt;
    private TFirst _First;&lt;br /&gt;
    public TSecond Second&lt;br /&gt;
    {&lt;br /&gt;
        get{ return _Second; }&lt;br /&gt;
        set{ _Second = value; }&lt;br /&gt;
    }&lt;br /&gt;
    private TSecond _Second;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generic IEquatable==&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.Collections.Generic;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
    public sealed class Pair&amp;lt;TFirst, TSecond&amp;gt;: IEquatable&amp;lt;Pair&amp;lt;TFirst, TSecond&amp;gt;&amp;gt;{&lt;br /&gt;
        private readonly TFirst first;&lt;br /&gt;
        private readonly TSecond second;&lt;br /&gt;
        public Pair(TFirst first, TSecond second)&lt;br /&gt;
        {&lt;br /&gt;
            this.first = first;&lt;br /&gt;
            this.second = second;&lt;br /&gt;
        }&lt;br /&gt;
        public TFirst First&lt;br /&gt;
        {&lt;br /&gt;
            get { return first; }&lt;br /&gt;
        }&lt;br /&gt;
        public TSecond Second&lt;br /&gt;
        {&lt;br /&gt;
            get { return second; }&lt;br /&gt;
        }&lt;br /&gt;
        public bool Equals(Pair&amp;lt;TFirst, TSecond&amp;gt; other)&lt;br /&gt;
        {&lt;br /&gt;
            if (other == null)&lt;br /&gt;
            {&lt;br /&gt;
                return false;&lt;br /&gt;
            }&lt;br /&gt;
            return EqualityComparer&amp;lt;TFirst&amp;gt;.Default.Equals(this.First, other.First) &amp;amp;&amp;amp;&lt;br /&gt;
                   EqualityComparer&amp;lt;TSecond&amp;gt;.Default.Equals(this.Second, other.Second);&lt;br /&gt;
        }&lt;br /&gt;
        public override bool Equals(object o)&lt;br /&gt;
        {&lt;br /&gt;
            return Equals(o as Pair&amp;lt;TFirst, TSecond&amp;gt;);&lt;br /&gt;
        }&lt;br /&gt;
        public override int GetHashCode()&lt;br /&gt;
        {&lt;br /&gt;
            return EqualityComparer&amp;lt;TFirst&amp;gt;.Default.GetHashCode(first) * 37 +&lt;br /&gt;
                   EqualityComparer&amp;lt;TSecond&amp;gt;.Default.GetHashCode(second);&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generic Interface==&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.Collections.Generic;&lt;br /&gt;
interface GenericInterface&amp;lt;T&amp;gt;              &lt;br /&gt;
{&lt;br /&gt;
   T getValue(T tValue);&lt;br /&gt;
}&lt;br /&gt;
class MyClass&amp;lt;T&amp;gt; : GenericInterface&amp;lt;T&amp;gt;     &lt;br /&gt;
{&lt;br /&gt;
   public T getValue(T tValue)    &lt;br /&gt;
   {&lt;br /&gt;
      return tValue;&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&amp;lt;int&amp;gt;    intObject    = new MyClass&amp;lt;int&amp;gt;();&lt;br /&gt;
      MyClass&amp;lt;string&amp;gt; stringObject = new MyClass&amp;lt;string&amp;gt;();&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, intObject.getValue(5));&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, stringObject.getValue(&amp;quot;Hi there.&amp;quot;));&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;
Hi there.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generic Interface for binary operation==&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.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
  public interface IBinaryOperations&amp;lt;T&amp;gt;&lt;br /&gt;
  {&lt;br /&gt;
    T Add(T arg1, T arg2);&lt;br /&gt;
    T Subtract(T arg1, T arg2);&lt;br /&gt;
    T Multiply(T arg1, T arg2);&lt;br /&gt;
    T Divide(T arg1, T arg2);&lt;br /&gt;
  }&lt;br /&gt;
  public class BasicMath : IBinaryOperations&amp;lt;int&amp;gt;&lt;br /&gt;
  {&lt;br /&gt;
    public BasicMath() {}&lt;br /&gt;
    public int Add(int arg1, int arg2)&lt;br /&gt;
    { return arg1 + arg2; }&lt;br /&gt;
    public int Subtract(int arg1, int arg2)&lt;br /&gt;
    { return arg1 - arg2; }&lt;br /&gt;
    public int Multiply(int arg1, int arg2)&lt;br /&gt;
    { return arg1 * arg2; }&lt;br /&gt;
    public int Divide(int arg1, int arg2)&lt;br /&gt;
    { return arg1 / arg2; }&lt;br /&gt;
    }&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      BasicMath m = new BasicMath();&lt;br /&gt;
      Console.WriteLine(&amp;quot;1 + 1 = {0}&amp;quot;, m.Add(1, 1));&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Implement multiple generic interfaces by a non-generic class==&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.Collections.Generic;&lt;br /&gt;
interface GenericInterface&amp;lt;T&amp;gt;                            &lt;br /&gt;
{&lt;br /&gt;
   T getValue(T inValue);&lt;br /&gt;
}&lt;br /&gt;
class MyClass : GenericInterface&amp;lt;int&amp;gt;, GenericInterface&amp;lt;string&amp;gt;    &lt;br /&gt;
{&lt;br /&gt;
   public int getValue(int inValue)            &lt;br /&gt;
   {&lt;br /&gt;
      return inValue;&lt;br /&gt;
   }&lt;br /&gt;
   public string getValue(string inValue)      &lt;br /&gt;
   {&lt;br /&gt;
      return inValue;&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 TrivInt = new MyClass();&lt;br /&gt;
      MyClass TrivString = new MyClass();&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, TrivInt.getValue(5));&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, TrivString.getValue(&amp;quot;Hi there.&amp;quot;));&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;
Hi there.&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>