crazyboybert
Programmer
Hi all
A bit of a theory question and my primary concern here is performance.
In my ASP.NET app I have an object which stores a collection as a CSV. This is necessary as the collection is generated on the client and is recieved as CSV by the object on postback.
I wish the object to have a read only public property which exposes this collection as an Array. The following code shows a simplified example of the class and another which uses it.
My concern is that everytime the code in B accesses the collection it will need to be rebuilt by the property getter in A. Is this the case or is the collection loaded into memory the first time the property is accessed and then retrieved from there each time afterwards?
Is this the best way to approach this or is there ar more suitable mehtod for exposing a collection as a property of a class?
Thanks
Rob
Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
A bit of a theory question and my primary concern here is performance.
In my ASP.NET app I have an object which stores a collection as a CSV. This is necessary as the collection is generated on the client and is recieved as CSV by the object on postback.
I wish the object to have a read only public property which exposes this collection as an Array. The following code shows a simplified example of the class and another which uses it.
Code:
public class A{
private csv = "1,2,3,4";
public string[] Items{
get{ return csv.Split(new char[] {','}); }
}
}
public class B{
public void method(){
A oA = new A();
for(int i=0; i<oA.Items.Length; i++){
//some processing on oA.Items[i]
}
}
}
Is this the best way to approach this or is there ar more suitable mehtod for exposing a collection as a property of a class?
Thanks
Rob
Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927