Indexer

Indexer is for accessing a list of value.

Indexer is accessed by using the index.

The following code uses the indexer from buildin type string to access each char inside a string.


using System;


class Program
{
    static void Main(string[] args)
    {
        string str = "java2s.com";

        Console.WriteLine(str[2]);


    }
}

The output:


v
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.