To answer the question in comments on why this is wanted you coudl define the isSet func normally and just use that as a method call which will have the same effect as your extension method but with different syntax.
The syntax difference in use is purely that you'll be passing the string in as a parameter rather than calling it as a method on that string.
A working example:
public void Method() { Func<string, bool> isSet = (x => x.Length > 0); List<string> testlist = new List<string>() {"", "fasfas", "","asdalsdkjasdl", "asdasd"}; foreach (string val in testlist) { string text = String.Format("Value is {0}, Is Longer than 0 length: {1}", val, isSet(val)); Console.WriteLine(text); } }
This method defines isSet as you have above (but without the this syntax). It then defines a list of test values and iterates over them generating some output, part of which is just calling isSet(val). Funcs can be used like this quite happily and should do what you want I'd think.
thisto add a new Method (not sure) but even if you did it would only be usable in runtime code (probably via reflection). I'm no expert though so this might be wrong but its what my gut tells me. :)funcin the same way as any other method. You'd be passing your string into it rather than calling it as an extension method but it seems to suit the spirit of what you are asking.