Skip to content

Instantly share code, notes, and snippets.

@LindaLawton
Created November 16, 2016 08:03
Show Gist options
  • Save LindaLawton/c92e42c428f021d369763b66335ecbea to your computer and use it in GitHub Desktop.
Save LindaLawton/c92e42c428f021d369763b66335ecbea to your computer and use it in GitHub Desktop.
testing out the different ways of Encapsulating a function.
private static string UppercaseString(string inputString)
{
return inputString.ToUpper();
}
delegate string ConvertMethod(string inString);
static void Main(string[] args)
{
var name = "linda";
ConvertMethod convertDeligate = UppercaseString;
Console.WriteLine(convertDeligate(name));
Func<string, string> GenericFunc = UppercaseString;
Console.WriteLine(GenericFunc(name));
Func<string, string> AnonymousFunc = delegate (string s) { return s.ToUpper(); };
Console.WriteLine(AnonymousFunc(name));
Func<string, string> convertLambda = s => s.ToUpper();
Console.WriteLine(convertLambda(name));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment