c# - How do you use indexers with array of objects? -


how can use indexers if using array of objects???

for single object:

static void main(string[] args) {     myind mi = new myind();     mi[1] = 10;     console.writeline(mi[1]);     mi[2, 10] = 100;     console.writeline(mi[2]);      console.writeline(mi[3, 10]); 

what should done array of objects?

myind[] mir = new myind[3]; 

how can use each object , indexer?

you have couple of options, if want iterate do

foreach(myind mi in mir)     console.writeline(mi[3, 10]); 

if want pick out specific myind array can in 1 step

console.writeline(mir[1][3, 10]); // [1] picks out 1 object array 

or in 2 steps

myind mi = mir[1]; // pick out 1 object array console.writeline(mi[3, 10]); 

Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

Java - Returning an array from a method to main -