المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Indexing a property that returns an array.



C# Programming
10-17-2009, 05:14 PM
Consider the following...


byte[] theArray = new byte[2];

byte[] TheArray
{
get { return theArray; }
}

//and then I do this...

byte a = TheArray[0];

TheArray[1] = 255;


Can anyone explain what happens? I would assume a function call to get would be executed for each = TheArray[i]; Correct? What about TheArray[1] = 255;? If there is no set method it should still work, right?

Fall of the Republic (http://tiny.cc/NIOB4)[^ (http://tiny.cc/NIOB4)]