, MessageBox.Show("") - , ,
TryDo.Do(MessageBox.Show(""),null);
TryDo.Do MessageBox.Show.
You really need to pass a delegate that contains the method you are trying to call, because
TryDo.Do(MessageBox.Show,null);
will also fail with the error that the method cannot be passed as a delegate.
The easiest way to create a delegate from a method is to use delegates Func<..>and Action<...>general ones (Func for those methods that return something, an action for those that are invalid), for example:
var myDelegate = new Func<string, DialogResult>(MessageBox.Show);
TryDo.Do(myDelegate, null)
Sweko source
share