Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Indexers Sample

Indexers Sample

This sample shows how C# classes can declare indexers to provide array-like access to the classes.

This sample contains the source code for the Indexers Tutorial.

Building and Running the Sample Within Visual Studio

To build and run the Indexers sample

  1. Open the solution (Indexers.sln).
  2. In Solution Explorer, right-click the indexers project and click Properties.
  3. Open the Configuration Properties folder and click Debugging.
  4. In the Command Line Arguments property, enter ..\..\Test.txt.
  5. Click OK.
  6. From the Debug menu, click Start Without Debugging.

Building and Running the Sample from the Command Line

To build and run the Indexers sample

  1. To compile the sample program, type the following at the command prompt:
    csc indexer.cs
    
  2. The sample program reverses the bytes in a file given as a command-line argument. For example, to reverse the bytes in Test.txt and see the result, issue the following commands:
    indexer Test.txt
    type Test.txt
    
  3. To change the reversed file back to normal, run the program on the same file again.

See Also

Indexers Tutorial | Tutorial Samples

Show:
© 2015 Microsoft