tags:

views:

116

answers:

3

This may sound like a bit of a dumb question but how do I make a Func<> variable that doesn't return anything?

+8  A: 

You can use Action<T> for a delegate that takes a variable and returns void.

But note that you can also just declare your own delegate types if you want to. Action<T>, for example, is just

public delegate void Action<T>(T obj)
Gabe Moothart
I don't know but is it necesary to usea delegate will the purpose not solved by only making the return type as void
Meetu Choudhary
You can't specify void (or Void) as a type argument.
Jon Skeet
but the question is about return type not for the agruments
Meetu Choudhary
+3  A: 

Will the Action<T> delegate work for you?

Action<T>

Jon Sagara
+2  A: 

You may want:

Action<T> a = (t) => // your code here...
jasonh