Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IEquatable_resolved
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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(t2,t2)); } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0.08 sec, absolute running time: 0.06 sec, cpu time: 0.05 sec, average memory usage: 16 Mb, average nr of threads: 4
fork mode
|
history
|
discussion
------------------ in Equals in Equals2 True