What are properties and indexer?

Answer Posted / soft.narayan@gmail.com

This answer posted by me soft.narayan@gmail.com,If u have
any query please let me know......

Using an object like an array is called Indexer.
Indexer is similar to properties.Indexer is a collection of
set and get procedures.Indexer name must be "this" only.
One class can have only one indexer.

Syntax to create Indexer:
string s
public string firstname
{
set{ s=value;}
get (return s;}
}

string[] x=new string[5];
public string this[inti]
{
set {x[i]=value}
get { return x[i]}
}
}

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is default method in c#?

700


Define thread?

751


Define an escape sequence, name few strings in escape sequence?

708


What is throw in c#?

680


What is the difference between values and reference types?

692


What is difference between .net and c#?

680


What do you mean by delegates and explain different types of delegates?

719


How to achieve polymorphism in c#?

724


What are types in c#?

671


In which way you can convert a value-type to a reference-type?

704


Is it possible to have different access modifiers on the get/set methods of a property in c#?

770


What is the use of 0 in c#?

714


how to print invert pyramid in c#

1487


What are the applications of c#?

1143


Explain how to add controls dynamically to the form using c#.net.

728