Each attribute of a class must have a unique name, and each indexer defined in the class must have a unique signature
Or a list of arguments so that you can implement the index reset. The property can be static, and the indexer must be an instance member. For cable
The access function defined by the primer can access the arguments passed to the indexer, and the property access function has no parameters. We can also
Port definition Indexer, when declaring an indexer for an interface, remember that the declaration simply represents the presence of the indexer, and you only need to provide a
You do not have to include modifiers when you access a function.
Look at the following case:
ITestIndex.cs file
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Algorithmdemo
{
interface itestindex
{
string This[int index]
{get
;
Set;}}}
TestIndex.cs file
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Algorithmdemo
{
class testindex<t>
{
private t[] arr = new t[100];
Public T This[int i]
{get
{return arr[i];}
set {Arr[i] = value;}}}
Program.cs
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Algorithmdemo
{
class program
{
static void Main (string[] args)
{
testindex< string> test = new testindex<string> ();
String data = "hello,world!";
for (int i = 0; i < data. Length; i++)
{
Test[i] = data[i]. ToString ();
}
for (int i = 0; i < data. Length; i++)
{
console.write (test[i]);
}
while (true);}}
Effect Chart: