Tony Johansson <jo*****************@telia.comwrote:
Below I have two different alternativ for where to declare the delegate
DoCalculate.
Is it possible to say something generally where to declare the delegate.
Is best within the class or outside the class. Or is just a matter of taste?
Alt 1
delegate double DoCalculate(double num);
class RocketCalculator
{
... ... ...
}
Alt 2
class RocketCalculator
{
public delegate double DoCalculate(double num);
... ... ...
}
If you're using .NET 3.5, I'd just stick to the Func and Action
delegates where possible, eg Func<double,doublein this case.
Otherwise, I personally like to have a "Delegates.cs" file containing
all of the delegates for a single namespace. I don't *usually* nested
them inside other classes, as it tends to make the code using them
slightly awkward.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
World class .NET training in the UK:
http://iterativetraining.co.uk