I am trying to create a list of the Components
running on the network. I am trying to get all the components in the ObservableCollection
. ObservableCollection<ClsComponent>
Now my question is if one of the component in the collection get changed / modified how would I be able to get it reflected to my ObservableCollection
of Component
- Is there a way to change the it directly in the collection itself?
- What is the fast and efficient way doing it?
I have tried: to change it using the LINQ : Find the Component
in the collection and change it?
var CompFound = Components.FirstOrDefault(x=>x.Id == myId);
Components.Remove(CompFound);
Components.Add(UpdatedComp);
I am very sure there should have been more optimized way of doing this. Please suggest.
Edit
I am trying to write the code in the function where I can get the parameters of Source Component
and Destination Component
. Function looks like this
public void UpdateComponent(ClsComponent SourceComp, ClsComponent DestComp)
{
//do something here
}
After the execution of the function I want to Replace Source Component with Destination Component.