Hello,
I have a generic collection class that looks something like this:
public class SignalEventList : List<SignalEvent>
{}
Whenever I add a new SignalEvent to a SignalEventList I want to perform a calculation:
public class SignalEventList : List<SignalEvent>
{
List<double> results = new List<double>;
private void doCalculation()
{
foreach(SignalEvent se in this) { results.Add(doCalculation(
));}
}
}
except, I am really sick of calling "doCalculation()" from client code. I get two lines: 1.) the actual Add(), 2.) the annoying call to doCalculation(). I want the client to be completely ignorant of the call to doCalculation(). So, what I want is the client to Add(SignalEvent) and then doCalculation() occurs behind the scenes.
In perl, I might do this with a Tie variable. Any ideas for C#?
Many thanks, please let me know if you need more clarification.
Start Free Trial