Revision: 34569
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 25, 2010 18:14 by yesraaj
Initial Code
using System; using System.Collections.Generic; using System.Text; namespace Raj { namespace Generics { class Node { private Node next_; public Node(Node next) { next_ = next; } public Node getNext() { return next_; } } internal sealed class TypeList<T> :Node { T data_; public T getData() { return data_; } public TypeList(T data, Node next):base(next) { data_ = data; } public TypeList(T data):this(data,null) { } public override String ToString() { return data_.ToString() + (base.getNext() != null ? base.getNext().ToString() : string.Empty); } //public override String ToString() //{ // String temp; // if (base.getNext() != null) // { // temp = base.getNext().ToString(); // } // else // { // temp = string.Empty; // } // return data_.ToString() + " " + temp; //} } class Dummmy:Object { public override String ToString() { return "Dummytype".ToString(); } } class Program { static void Main(string[] args) { Dummmy dummy = new Dummmy(); Node list = new TypeList<int>(12); list = new TypeList<Double>(12.5121, list); list = new TypeList<Dummmy>(dummy, list); Double a = ((TypeList<Double>)list).getData(); Console.WriteLine(list.ToString()); Console.Write("sds"); } } } }
Initial URL
Initial Description
Initial Title
List of different type
Initial Tags
list
Initial Language
C#