Microsoft .NET Interview Questions and Answers
Ques 31. Write code to show how a method can accept a varying number of parameters.
using System;
namespace Console1
{
class Class1
{
static void Main(string[] args)
{
ParamsMethod(1,"example");
ParamsMethod(1,2,3,4);
Console.ReadLine();
}
static void ParamsMethod(params object[] list)
{
foreach (object o in list)
{
Console.WriteLine(o.ToString());
}
}
}
}
Ques 32. What is an overloaded method?
An overloaded method has multiple signatures that are different.
Ques 33. What is recursion?
Recursion is when a method calls itself.
Ques 34. What is a constructor?
A constructor performs initialisation for an object (including the struct type) or class.
Ques 35. If I have a constructor with a parameter, do I need to explicitly create a default constructor?
Yes
Most helpful rated by users:
- Name 10 C# keywords.
- What is public accessibility?
- .NET Stands for?
- What is private accessibility?
- What is protected accessibility?