Introduction:
Indexers are location indicators and are used to access class objects,just like accessing elements in an array.they are useful in cases where a class is a container for other objects.here example uses indexers and makes an array of 15 values,stores a few values in the arrayand the null values of array from 12 position are stored with the words "empty".
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IndexersExample
{
class indexersEx
{
private string[] TechCompanies = new string[14];
public string this[int indexval]
{
get
{
if (indexval < 0 || indexval >= 11)
return "empty";
else
return TechCompanies[indexval];
}
set
{
if (!(indexval < 0 || indexval >= 11))


Join the conversation! Your thoughts help the community grow.