Tuesday, 15 April 2014

linq - C# Lambda with Console.Read -



linq - C# Lambda with Console.Read -

i asking myself quite few days , time need help on this..

i have sample code looks

int ntestcase = convert.toint32(console.readline()); string[] inputstrings = new string[ntestcase]; (int =0; i<ntestcase;i++) { inputstrings[i] = console.readline(); }

is there possibility avoid extensive loop on here. thought of replacing lambda expresssions?

this question might sound crazy, want know whether lambda can handle console.read scenario?

int ntestcase = convert.toint32(console.readline()); string[] inputstrings = enumerable.range(0, ntestcase) .select(x => console.readline()) .toarray();

or even

string[] inputstrings = enumerable.range(0, convert.toint32(console.readline())) .select(x => console.readline()) .toarray();

linq c#-4.0 lambda console-application

No comments:

Post a Comment