Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Gen inheritance 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 NonGen { public int num; public string s; public NonGen() { //NonGen ng=new NonGen(); } public NonGen(int i) { num = i; } public NonGen(int i,string st) { num = i;s=st; } public int GetNum() { return num; } } // A generic derived class. class Gen<T> : NonGen { public T ob; public int j; public Gen<object> ng; public Gen() { ng=new Gen<object>(); } public Gen(T o) { } public Gen(T o, int i) : base (i) { ob = o;j=i; } // Return ob. public T GetOb2() { ng.ob=ob;ng.j=j; return (Gen<object>)ng; } public T GetOb() { return ob; } } public class Program { public static void Main(string[] args) { // Create a Gen object for string. Gen<string> w = new Gen<string>("Hello", 47); Gen<string> w2 = new Gen<string>(); w2=w.GetOb2(); NonGen n=new NonGen(12,"Oye"); /*Console.Write(w.GetOb() + "_ "); Console.WriteLine(w.GetNum());*/Console.WriteLine(); Console.Write(n.num+" "+n.s+" "+w.j); } } }
run
|
edit
|
history
|
help
0
helloworld_java
test
HourCouter
test_hash
C# queue
Pascal Tringle
Stacks: Balanced Brackets -final
arrays bidimencionales y tridimencionales
codetility CyclicRotation
Get Error Message Based on String