diff options
author | Geoff Liu <g@geoffliu.me> | 2015-01-18 13:07:39 -0700 |
---|---|---|
committer | Geoff Liu <g@geoffliu.me> | 2015-01-18 13:07:39 -0700 |
commit | 31faf1a6a1c35802cf3676ec1a7f54d86411b566 (patch) | |
tree | 5ccca54b8837fec9a8d6d60d2bda6db4162078e7 /csharp.html.markdown | |
parent | 40c38c125b94430b518d7e402d595694149b7c53 (diff) | |
parent | c053f1559bb357d9e8ced2452096bf3a95cc7ddb (diff) |
Merge branch 'master' of github.com:geoffliu/learnxinyminutes-docs
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r-- | csharp.html.markdown | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown index f6708590..47dd9683 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -678,6 +678,23 @@ on a new line! ""Wow!"", the masses cried"; private set; } + // It's also possible to define custom Indexers on objects. + // All though this is not entirely useful in this example, you + // could do bicycle[0] which yields "chris" to get the first passenger or + // bicycle[1] = "lisa" to set the passenger. (of this apparent quattrocycle) + private string[] passengers = { "chris", "phil", "darren", "regina" } + + public string this[int i] + { + get { + return passengers[i]; + } + + set { + return passengers[i] = value; + } + } + //Method to display the attribute values of this Object. public virtual string Info() { |