C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Indexers in C#


Posted Date: 10 Jun 2008    Resource Type: Definitions    Category: General

Posted By: Kumar Velu       Member Level: Diamond
Rating:     Points: 4



C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. Defining a C# indexer is much like defining properties.



Responses

Author: mahendrakiran    13 Nov 2008Member Level: Gold   Points : 2
C# introduces a new concept known as Indexers which are used for treating an object as an array.

The indexers are usually known as smart arrays in C# community.
Defining a C# indexer is much like defining properties.
We can say that an indexer is a member that enables an object to be indexed in the same way as an array.

this [argument list]
{
get
{
// Get codes goes here
}
set
{
// Set codes goes here
}
}

Where the modifier can be private, public, protected or internal.
The return type can be any valid C# types.
The 'this' is a special keyword in C# to indicate the object of the current class.
The formal-argument-list specifies the parameters of the indexer.
The formal parameter list of an indexer corresponds to that of a method, except that at least one parameter must be specified, and that the ref and out parameter modifiers are not permitted.
Indexers in C# must have at least one parameter.

The indexers in C# can be overloaded just like member functions.
The formal parameter list of an indexer defines the signature of the indexer.
Specifically, the signature of an indexer consists of the number and types of its formal parameters.
The element type is not part of an indexer's signature, nor is the names of the formal parameters.
The signature of an indexer must differ from the signatures of all other indexers declared in the same class.
C# do not have the concept of static indexers.
If we declare an indexer static, the compiler will show a compilation time error.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: SQL Injection
Previous Resource: Namespaces
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it help desk

Contact Us    Privacy Policy    Terms Of Use