-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: rajesh_mr
Message 2 in Discussion

Hi  
An indexer enables you to treat an object like an array.It helps you to acces 
the arrays in a class using the class name. Indexer enables you to use bracket 
notation ([]) with an object to set and get a value from an object.They 
encapsulate method calls into more convenient representation of value access 
and value setting.
 
public dataType this[int index]
{
  get
  { 
     //Code to get some value from a array 
     if (index < 0)
                return "negative";
            else if (index > max)
                return "Infinity";
            else
                return arr[index];
      }
  set
  { 

     arr[index]=value; 
  }
}    
 
Indexers makes your code more readable and easier to understand. 
You can create mulltiple indexers for a class.  Signature of each indexer 
should be unique.  The signature of an indexer is considered as the number and 
types of its formal parameters return data type of the indexer is not part of 
signature. 

    They help you to represent as array values which may have no similarities 
to arrays as internal representation.

    You are not limited to using integers as indexes. You can use strings to 
achieve the result used in the Hash class and many others.  
Use indexer only when the representation of the class data as multiple objects 
is proper.  
Regards 
Rajesh

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to