-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E.g. ``` public string this[int i] { get { ... } } ``` Related to #1392
- Loading branch information
Showing
2 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
class HelloWorldIndexer | ||
{ | ||
public static void Main() | ||
{ | ||
var instance = new HelloWorldIndexer(); | ||
Console.WriteLine(instance[0]); | ||
Console.WriteLine(instance[1]); | ||
} | ||
|
||
private string this[int i] | ||
{ | ||
get | ||
{ | ||
switch (i) | ||
{ | ||
case 0: return "hello"; | ||
case 1: return "world"; | ||
default: throw new IndexOutOfRangeException(); | ||
} | ||
} | ||
set => throw new NotImplementedException(); | ||
} | ||
} |