-
Notifications
You must be signed in to change notification settings - Fork 1
Indexer Methods
Mario Gutierrez edited this page Jan 7, 2017
·
1 revision
Basic implementation.
public ReturnType this[int i]
{
get { return (ReturnType)internalList[i]; }
set { internalList[i] = value; }
}
Can use indexing by non-integer types too.
public ReturnType this[string s] {
/* ... */
}
Multidimensional indexing.
public ReturnType this[string a, string b] {
/* ... */
}
These can be overloaded so you can use multiple methods of indexing with your custom type.
You can also specify them in an interface.
public interface IMyContainer
{
string this[int index] { get; set; }
}
- Abstract Classes
- Access Modifiers
- Anonymous Methods
- Anonymous Types
- Arrays
- Attributes
- Console I/O
- Constructors
- Const Fields
- Delegates
- Enums
- Exceptions
- Extension Methods
- File IO
- Generics
- Interfaces
- Iterators
- LINQ
- Main
- Null Operators
- Parameters
- Polymorphism
- Virtual Functions
- Reflection
- Serialization
- Strings
- Value Types
- "Base" Keyword
- "Is" and "As"
- "Sealed" Keyword
- nameof expression