The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft