plugins: plugin loader redesign
[geany-mirror.git] / tests / ctags / interface_indexers.cs
blob64531a3fbc1ae083c536e6c15338c25c052bbc8b
1 // cs_interface_indexers.cs
2 using System;
3 // Indexer on an interface:
4 public interface IMyInterface
6 // indexer declaration:
7 int this[int index]
9 get;
10 set;
14 // Implementing the interface:
15 class IndexerClass : IMyInterface
17 private int [] myArray = new int[100];
18 public int this [int index] // indexer declaration
20 get
22 // Check the index limits
23 if (index < 0 || index >= 100)
24 return 0;
25 else
26 return myArray[index];
28 set
30 if (!(index < 0 || index >= 100))
31 myArray[index] = value;
36 public class MainClass
38 public static void Main()
40 IndexerClass b = new IndexerClass();
41 // call the indexer to initialize the elements #3 and #5:
42 b[2] = 4;
43 b[5] = 32;
44 for (int i=0; i<=10; i++)
46 Console.WriteLine("Element #{0} = {1}", i, b[i]);