Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ListeFULL_CON
- {
- class Program
- {
- class Liste<T>
- {
- /* Datenfelder */
- LElement<T> root;
- /* Konstruktor */
- public Liste()
- {
- this.root = null;
- }
- class LElement<TYP>
- {
- /* Datenfelder */
- LElement<TYP> next;
- TYP content;
- /* Konstruktor */
- public LElement()
- {
- this.next = null;
- }
- /* Property */
- public LElement<TYP> Next
- {
- get { return this.next; }
- set { this.next = value; }
- }
- }
- /* Methoden */
- public void Add(T c)
- {
- LElement<T> neu = new LElement<T>();
- neu.Next = this.root;
- this.root = neu;
- }
- /* Indexer */
- public LElement<T> this[int index]
- {
- get
- {
- LElement<T> temp = new LElement<T>();
- temp = this.root;
- while (index >= 0 && temp != null)
- {
- temp = temp.Next;
- index--;
- }
- return temp;
- }
- set
- {
- LElement<T> temp = new LElement<T>();
- temp = this.root;
- while (index >= 0 && temp != null)
- {
- temp = temp.Next;
- index--;
- }
- temp = value;
- }
- }
- }
- static void Main(string[] args)
- {
- Liste<int> integers = new Liste<int>();
- integers.Add(1);
- integers.Add(2);
- integers.Add(3);
- integers.Add(4);
- Console.WriteLine(integers[3]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement