Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
last ie
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 delegate bool comp<T>(T t); public delegate bool comp<T,V>(T t,V v); public class ByOne<T,V> where T: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 Test { public bool Equals<T,V>(T tp,V vp) where T:IEquatable<Test> { if(tp.Equals(vp)) { Console.WriteLine("in Equals"); return true; } else { Console.WriteLine("in Equals"); return false; } } } public class Program { public static void Main(string[] args) { Console.WriteLine("ByOne\n\n"); 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); Test t=new Test(); Test t1=new Test(); Test t2=new Test(); ByOne<object,object> bone3=new ByOne<object,object>(t,t); //ByOne<object,object> bone5=new ByOne<object,object>(bone); //ByOne<object,object> bone6=new ByOne<object,object>(bone5);*/ Console.WriteLine(me1.Equals(me2)); Console.WriteLine(me1.Equals(me1)); Console.WriteLine(me2.Equals(me1)); Console.WriteLine("------------------"); Console.WriteLine(); t.Equals(bone,bone); } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0.11 s
edit mode
|
history
|
discussion