Skip to content

Instantly share code, notes, and snippets.

@rozer007
Created November 24, 2021 06:43
Show Gist options
  • Save rozer007/b69125294b40f47db3ff96bdd8c6a19b to your computer and use it in GitHub Desktop.
Save rozer007/b69125294b40f47db3ff96bdd8c6a19b to your computer and use it in GitHub Desktop.
Delegate and lambda expression and files in c#
Q1 can a static method associated with a class having same parameter and retunn typecall delegate?
ans : yes , it can be call just the return typr and parameter must be satisfied.
Q2 What is a lambda operator?
ans: this "=>" is known as the lambda operator in c#.
Q3. How can we know that we have reach the end of a file while reading file?
ans: we just need to check if the file.ReadLine == null, if null then it had reached the end.
Q4 What is anonymous function?
ans It is a function with not name , just body.
Q1 what is correct way of declaring a delegate name print with one argument?
a. public delegate print();
b. public void print delegate(arg);
c. public delegate void print(arg);
d none of the above
ans: c)
Q2 what is correct to this statement
Func<int,int,int> name;
a. take 3 parameter
b. take 1 paramter as input , one as output and the last is for default
c. the first two is input parameter and the last is output parameter
d.none of the above
ans: d)
Q3) What is correct method to call a lambda expression
a. func_name();
b. func_name.call();
c. func_name.invoke();
d. Both a and c
ans c
Q4) what will be the output:
List<int> lt=newList<int>{1,2,3,4,5,6};
List<int> en =lt.Where(n=>n%2==0).ToList();
foreach(int i in en)
{
Console.Write(i);
}
a) 123456
b) 135
c) 2 4 6
d)246
ans: d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment