Wednesday 15 June 2011

Determine which index of an array property is being set using c# -


I am creating an OPC client so that one can read the tag of an electrical appliance. This is done by establishing objects in an OPC group. I need a property that has an array of bool [] to set objects as active or inactive. I have to know which index of the property was used to set up the property so that I could use it to activate the item. I could have used only one method but liked one property. _the group is the OPC group that holds the items.

  Private Bull [] _ItemActive; Public Bull [] Item Functional {Return {ITMactive; } Set {if (_theGroup! = Null) {int itemIndex = ?? // I do not know how to get property index access by user int itemhandle = itemhand [item index]; // handle uses the index to find _thegroup.SetActiveState (itemHandle, value, fault out); // Use to activate the item) _ItemActive = value; }}   

The user can do something like this.

  opcClient.itemActive [3] = Wrong;   

I need to be able to search for 3 and plug it in the items shown above in the set of my bottle array []

You can create a custom collection with an override indexer operator, where you want to custom logic. But creating a setter method looks like a setItem activation (int, boole) a cleaner solution.

No comments:

Post a Comment