Compare input string with Lambda expression

  • Thread starter Thread starter Abhijeet Khopade
  • Start date Start date
A

Abhijeet Khopade

Guest
Hi Guys,

I have simple query in C# with Lambda expression. If I dont want to use IF/ELSE and Switch then I can use Lambda. I did that but not getting proper output

Below is my simple sample code

static void Main(string[] args)
{
Console.WriteLine("Please provide input (ex-a/b/b etc):");
string s = Console.ReadLine();
string sOut = string.Empty;
var sCheck = new Dictionary<string, Func<string>>()
{
{ "a", () => sOut = "Some logic here"},
{ "b", () => sOut ="Something else here"},
{ "c", () => sOut ="Ofcourse more than just print statement"}
};

Console.WriteLine("Output for {0} should be : {1}",s,sOut);
Console.ReadLine();
}


So if i enter a it should print statement for a. but I am getting blank.


Abhijeet Khopade

Continue reading...
 
Back
Top