G
Guest
Hello,
Iam writing an interface in c# , where two of the methods look like this -
ParameterCollection DependentProperties
{get;}
ParameterCollection IndependentProperties
{get;}
ParameterCollection = stronly typed collection of MyParameter objects.
MyParameter is a class with 3 string and 3 double properties.
I dont want the user to modify the DependentProperties collection, so I make
it readonly property, and in turn return a copy of the underlying collection.
But with the IndependentProperties property, I want the user to be able to
modify the objects contained in the collection (NOT modify the collection).
Currently, it works as follows -
I return a copy of the underlying collection, (and copy of objects contained
in it). The ParameterCollection class has a method, UpdateCollection that can
transfer values as follows:
void UpdateCollection(ParameterCollection pc)
{
for(i =0; i <this.count;i++)
this.Value = pc.Value;
// Where Value is a property of the MyParameter object, which is the only
one that can be changed by the user. The user cannot change other properties
of MyParameter objects, but uses them for display purposes.
}
My question is , is there a better way of doing this ?
thank you,
vikrantca
Iam writing an interface in c# , where two of the methods look like this -
ParameterCollection DependentProperties
{get;}
ParameterCollection IndependentProperties
{get;}
ParameterCollection = stronly typed collection of MyParameter objects.
MyParameter is a class with 3 string and 3 double properties.
I dont want the user to modify the DependentProperties collection, so I make
it readonly property, and in turn return a copy of the underlying collection.
But with the IndependentProperties property, I want the user to be able to
modify the objects contained in the collection (NOT modify the collection).
Currently, it works as follows -
I return a copy of the underlying collection, (and copy of objects contained
in it). The ParameterCollection class has a method, UpdateCollection that can
transfer values as follows:
void UpdateCollection(ParameterCollection pc)
{
for(i =0; i <this.count;i++)
this.Value = pc.Value;
// Where Value is a property of the MyParameter object, which is the only
one that can be changed by the user. The user cannot change other properties
of MyParameter objects, but uses them for display purposes.
}
My question is , is there a better way of doing this ?
thank you,
vikrantca