Content deleted Content added
m cite repair; |
→Example: adjust code |
||
Line 11:
| website= .net Funda
| title = C# Interview Questions
| url =
<syntaxhighlight lang="csharp">
class
{
public OurFamily(params string[] pMembers)▼
{
}
▲ private List<string> familyMembers;
public string this[int index]
{
// The get accessor
get => _familyMembers[index];
// The set accessor with
▲ familyMembers[index] = value;
}
Line 42 ⟶ 36:
{
// Getting index by value (first element found)
▲ return familyMembers.FindIndex(m => m == val);
}
public int Length =>
}
</syntaxhighlight>
Line 58 ⟶ 48:
void Main()
{
var doeFamily = new
for (int i = 0; i < doeFamily.Length; i++)
{
Line 70 ⟶ 60:
In this example, the indexer is used to get the value at the nth position, and then to get the position in the list referenced by its value.
The output of the code is:
== See also ==
|