Windows: fix possible buffer overflows
[geany-mirror.git] / tests / ctags / indexer.cs
blob437d360643c01294aafff08829cd93fe699c8b30
1 // cs_keyword_indexers.cs
2 using System;
3 class IndexerClass
5 private int [] myArray = new int[100];
6 public int this [int index] // indexer declaration
8 get
10 // Check the index limits
11 if (index < 0 || index >= 100)
12 return 0;
13 else
14 return myArray[index];
16 set
18 if (!(index < 0 || index >= 100))
19 myArray[index] = value;
24 public class MainClass
26 public static void Main()
28 IndexerClass b = new IndexerClass();
29 // call the indexer to initialize the elements #3 and #5:
30 b[3] = 256;
31 b[5] = 1024;
32 for (int i=0; i<=10; i++)
34 Console.WriteLine("Element #{0} = {1}", i, b[i]);