Indexer question
-
Hi, I have a small problem. I want to create 2 properties to one of my classes. All I want is to make easier for the users of my class to get some data out of my class. I want when a user writes
Test[i]
to get some data and when the user writes
Test[i][j]
to get another type of response. I need a little help with the second type of property:
public class Test
{
//some datapublic object this[int index]
{
get
{
//get data
}
}
}This one works. My question is how to write the second one? Thanks in advance
Do your best to be the best
-
Hi, I have a small problem. I want to create 2 properties to one of my classes. All I want is to make easier for the users of my class to get some data out of my class. I want when a user writes
Test[i]
to get some data and when the user writes
Test[i][j]
to get another type of response. I need a little help with the second type of property:
public class Test
{
//some datapublic object this[int index]
{
get
{
//get data
}
}
}This one works. My question is how to write the second one? Thanks in advance
Do your best to be the best
The second is a result of the first.
Test[i][j]
can be broken down like this:B someB = someA[i];
object result = someB[j];or it can be written in a compressed form like this:
object result = someA[i][j];
The classes look like this:
public A
{
public B this[int index]
{
get
{
return stuff
}
}
}public B
{
public object this[int index]
{
get
{
return stuff
}
}}
Does this help?
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
-
Hi, I have a small problem. I want to create 2 properties to one of my classes. All I want is to make easier for the users of my class to get some data out of my class. I want when a user writes
Test[i]
to get some data and when the user writes
Test[i][j]
to get another type of response. I need a little help with the second type of property:
public class Test
{
//some datapublic object this[int index]
{
get
{
//get data
}
}
}This one works. My question is how to write the second one? Thanks in advance
Do your best to be the best
-
The second is a result of the first.
Test[i][j]
can be broken down like this:B someB = someA[i];
object result = someB[j];or it can be written in a compressed form like this:
object result = someA[i][j];
The classes look like this:
public A
{
public B this[int index]
{
get
{
return stuff
}
}
}public B
{
public object this[int index]
{
get
{
return stuff
}
}}
Does this help?
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
Thanks a lot. It really works :-D
Do your best to be the best
-
Hi, I have a small problem. I want to create 2 properties to one of my classes. All I want is to make easier for the users of my class to get some data out of my class. I want when a user writes
Test[i]
to get some data and when the user writes
Test[i][j]
to get another type of response. I need a little help with the second type of property:
public class Test
{
//some datapublic object this[int index]
{
get
{
//get data
}
}
}This one works. My question is how to write the second one? Thanks in advance
Do your best to be the best
Why don't you add another indexer with 2 parameters.