/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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) { Double a = ((TypeList<Double>)list).getData(); Console.WriteLine(list.ToString()); Console.Write("sds"); } } } }