Asp.net C#: what is an indexer in C# how to use indexers?

Asp.net C#: what is an indexer in C# how to use indexers?

An Indexer in C#:

C# provides a new functionality called indexers which are use for treating as an object of array. The indexers are usually known as smart array in C#. Defining an indexer is much like defining a property.






So we can say that the indexer is a member that enables an object to be indexed in the same way as an array.

Syntax of indexer in C#:

<Modifier><return type> this [argument list]
{
Get
{
// get codes goes here
}
Set
{
// set codes goes here
}
}

Where modifier can be private, public or protected etc.

And ‘this’ is this is a special keyword in C# to indicate the object of current class.

Comments

  1. Wow! Nice post. After reading this blog, I got some information about indexer and how to use this in Asp.net C#. I have a little bit knowledge about Running ASP.NET 5 applications in Linux Containers. When I hosted my website I got this idea from there. Thanks a lot for sharing this nice info.

    ReplyDelete

Post a Comment