Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
Indexer issue in call for in Main
Avinash Vajpayee
7y
157
1
Reply
How I Call this indexer in main class for differ in variable i,x,y
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
ConsoleApplication1
{
using
System;
class
SampleCollection
{
// Declare an array to store the data elements.
private
T[] arr =
new
T[100];
private
P[] prr =
new
P[100];
private
U[] urr =
new
U[100];
// Define the indexer to allow client code to use [] notation.
public
T
this
[
int
i]
{
get
{
return
arr[i]; }
set
{ arr[i] = value; }
}
// Define the indexer to allow client code to use [] notation.
public
P
this
[
int
x]
{
get
{
return
prr[x]; }
set
{ prr[x] = value; }
}
// Define the indexer to allow client code to use [] notation.
public
U
this
[
int
y]
{
get
{
return
urr[y]; }
set
{ urr[y] = value; }
}
}
class
Program
{
static
void
Main()
{
var stringCollection =
new
SampleCollection();
for
(
int
i = 0; i < 200;i++ )
{
stringCollection[i] =
new
{
"Hello, World"
,1,1};
Console.WriteLine(stringCollection[i]);
}
Console.ReadKey();
}
}
// The example displays the following output:
// Hello, World.
}
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
how to load images from database to bootsatrap carousel (mvc
How to create Rules in Visual Studio 2017?