Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ListeFULL_CON
  7. {
  8.     class Program
  9.     {
  10.         class Liste<T>
  11.         {
  12.             /* Datenfelder */
  13.             LElement<T> root;
  14.  
  15.             /* Konstruktor */
  16.             public Liste()
  17.             {
  18.                 this.root = null;
  19.             }
  20.  
  21.             class LElement<TYP>
  22.             {
  23.                 /* Datenfelder */
  24.                 LElement<TYP> next;
  25.                 TYP content;
  26.  
  27.                 /* Konstruktor */
  28.                 public LElement()
  29.                 {
  30.                     this.next = null;
  31.                 }
  32.  
  33.                 /* Property */
  34.                 public LElement<TYP> Next
  35.                 {
  36.                     get { return this.next; }
  37.                     set { this.next = value; }
  38.                 }
  39.             }
  40.  
  41.             /* Methoden */
  42.             public void Add(T c)
  43.             {
  44.                 LElement<T> neu = new LElement<T>();
  45.                 neu.Next = this.root;
  46.                 this.root = neu;
  47.             }
  48.  
  49.             /* Indexer */
  50.             public LElement<T> this[int index]
  51.             {
  52.                 get
  53.                 {
  54.                     LElement<T> temp = new LElement<T>();
  55.                     temp = this.root;
  56.                     while (index >= 0 && temp != null)
  57.                     {
  58.                         temp = temp.Next;
  59.                         index--;
  60.                     }
  61.                     return temp;
  62.                 }
  63.                 set
  64.                 {
  65.                     LElement<T> temp = new LElement<T>();
  66.                     temp = this.root;
  67.                     while (index >= 0 && temp != null)
  68.                     {
  69.                         temp = temp.Next;
  70.                         index--;
  71.                     }
  72.                     temp = value;
  73.                 }
  74.             }
  75.         }
  76.  
  77.         static void Main(string[] args)
  78.         {
  79.             Liste<int> integers = new Liste<int>();
  80.             integers.Add(1);
  81.             integers.Add(2);
  82.             integers.Add(3);
  83.             integers.Add(4);
  84.             Console.WriteLine(integers[3]);
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement