Select chapter



Basics (2.papers)
Data Types (2.papers)
enums (2.papers)
OOPS (4.papers)
Arrays (1.papers)
Structs (2.papers)
Properties (2.papers)
Strings (2.papers)
Interfaces (1.papers)
Constructors (2.papers)
Ref-Out-Keywords (1.papers)
Collections (2.papers)
Generics (1.papers)
Hide

Sponsored Links


  

c# interview questions and answers

1
What is an Extension Method in C#?
  1. An extension method is a method which we can add it to an existing type.
  2. An Extension method is a static method which we can add it to an instance type without recompiling the code.
  3. Using extension methods we can "add" methods to existing types without creating a new derived type.
  4. All the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
Which of the below syntax is correct way of creating an extension method ?
  1. public static class A
    {
        public static string M(this string data)
        {
            return "something";
        }
    }
  2. public static class A
    {
        public string M(this string data)
        {
            return "something";
        }
    }
  3. public class A
    {
        public static string M(this string data)
        {
            return "something";
        }
    }
  4. public class A
    {
        public string M(this string data)
        {
            return "something";
        }
    }
Show Answer
Share Facebook gmail Twitter
5
Which of the below statements are correct about extension methods in C#?
  1. Extension methods are defined as static methods but are called like instance methods
  2. The first parameter of an extension method should be always preceded by this keyword
  3. Extension methods will come into scope only when you import namespace into your source code .
  4. All the above statements are correct .
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :