Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Generics Operator test
//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 { class Gen<T> { T ob1,ob2; public Gen(ref T o,ref T p) { ob1=o; ob2=p; } public T GetOb() { return (ob1+ob2); //return ob1; } public object GetObAdd<T>(object ob1,object ob2) { return (ob1+ob2); //return ob1; } /* public T GetOb1() { return ob1; } public T GetOb2() { return ob2; } */ public void ShowType() { Console.WriteLine("Type of T is " + typeof(T)); } } public class Program { public static void Main(string[] args) { // Gen<T> test = new Gen<T>(T,T); //Gen<int> iOb; dynamic iOb; int x,y; x=100;y=200; iOb = new Gen<int>(ref x,ref y); iOb.ShowType(); int v = iOb.GetOb(); Console.WriteLine("value: " + v); /*int v1 = iOb.GetOb1(); Console.WriteLine("value: " + v1); int v2 = iOb.GetOb2(); Console.WriteLine("value: " + v2);*/ Console.WriteLine(); string s1,s2; s1="Hii"; s2="Generics add power."; iOb = new Gen<string>(ref s1,ref s2); iOb.ShowType(); string str = iOb.GetOb(); Console.WriteLine("value: " + str); /* string str1 = strOb.GetOb1(); Console.WriteLine("value: " + str1); string str2 = strOb.GetOb2(); Console.WriteLine("value: " + str2);*/ //iOb=strOb; //iOb.ShowType(); } } }
run
|
edit
|
history
|
help
0
transform string to hex code
Linq - When using FirstOrDefault, make sure to check for null result
Multithreading
1 through 1000
3
Calculator
String combinations
test string format with curly braces as a value
name generator
ashok