Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IEqatable simple object compare
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class ByOne<T,V>:IEquatable<T> { public T t; public V v; public ByOne(T a) { t=a; } public ByOne(T a,V b) { t=a; v=b; } public ByOne() { t=default(T); v=default(V); } public bool Equals(T tp) { if(this.Equals(tp)) return true; else return false; } public bool Equals(T tp,V vp) { if(tp.Equals(vp)) { Console.WriteLine("in Equals"); return true; } else { Console.WriteLine("in Equals"); return false; } } /* public bool Equals(V vp) { if(this.Equals(vp)) return true; else return false; }*/ } public class Test2:IEquatable<Test2> { int val; public bool Equals(Test2 other) { Console.WriteLine("in Equals"); return val == other.val; } } public class Test { public Test() { } public bool Equals2<T>(T tp,T vp) where T:IEquatable<T> { if(tp.Equals(vp)) { Console.WriteLine("in Equals2"); return true; } else { Console.WriteLine("in Equals2"); return false; } } } public class Program { public static void Main(string[] args) { int me1=10; double me2=15.2; byte me3=10; float me4=6.1F; ByOne<int,double> bone=new ByOne<int,double>(me1,me2); ByOne<int,double> bone1=new ByOne<int,double>(me3,me2); ByOne<int,double> bone2=new ByOne<int,double>(me3,me4); ByOne<object,object> bone3=new ByOne<object,object>(bone,bone1); ByOne<object,object> bone4=new ByOne<object,object>(bone1,bone2); Console.WriteLine("------------------"); Console.WriteLine(); Test t=new Test(); Test2 t1=new Test2(); Test2 t2=new Test2(); Console.WriteLine(t.Equals2(t1,t1)); } } }
run
|
edit
|
history
|
help
0
dsfafasd
subtração
Best Exam Collection site
ADSA - Tuto 1 - Exo4 - b - Proposition d'algo en O(n)
30272 Program Ex7_1 switch_int
project euler 10, C#
pyramidalt
sdfnmj,k, mnfdc
Types
Array 10th grade