C# Interview Questions and Answers
C# : How do you add button to form using c# code?

How do you add button to form using c# code?

Button btn = new Button(); //set button properties Form.Controls.Add(btn);
Category: C# Date: 10/15/2010 10:27:47 AM
C# : How do you declare destructor in c#?

How do you declare destructor in c#?

class T { ~T() { /*destructor code*/}}
Category: C# Date: 10/15/2010 8:23:46 AM
C# : What will be the result of this code Console.WriteLine(3/4 == 3.0/4.0);

What will be the result of this code Console.WriteLine(3/4 == 3.0/4.0);

answer is 'false'
Category: C# Date: 10/15/2010 7:40:47 AM
C# : What will be the result of the code Console.Write(String.Format(“{0:dd MMM yyyy}”, new DateTime(2009,12,23))?
C# : What will contain list t after following code?
List<int> t = new List<int>() {1,2,3};
t.ForEach((i) => i = i *2);
C# : How do you select even numbers using Where extension method on List<int>?

How do you select even numbers using Where extension method on List?

data.Where( I => I %2 == 0);
Category: C# Date: 10/15/2010 4:53:47 AM
C# : What will be the result of the following code:
struct T {public int A;}
static void Main(string[] args)
{
T a = new T();
a.A = 10;
T b = a;
a.A = 1;
Console.WriteLine(a.A == b.A);
}
C# : How do you use nullable types?

How do you use nullable types?

int? num = null; //declaration if(num.HasValue == true) Console.Write(num.Value); else Console.Write....
Category: C# Date: 10/15/2010 3:09:46 AM
C# : How can you access system clipboard from c#?

How can you access system clipboard from c#?

By using Clipboard object. For example – SetText – sets text in clipboards, GetText – returns text f....
Category: C# Date: 10/15/2010 2:59:46 AM
C# : How do you start another process from c#?

How do you start another process from c#?

Process p = new Process(); p.StartInfo.FileName =”notepad.exe”; p.Start();
Category: C# Date: 10/15/2010 2:16:47 AM
C# : Can you declare static variable in method scope?

Can you declare static variable in method scope?

No
Category: C# Date: 10/15/2010 12:22:46 AM
C# : What will be the result of code?
int x = 3;
switch(x % 3)
{
 case 0:
 case 1:
  Console.WriteLine(x*2); break;
 default:
  Console.WriteLine(x); break;
}
C# : Write a code to copy file from path1 to path2 using FileStreams and BinaryReader, BinaryWriter

Write a code to copy file from path1 to path2 using FileStreams and BinaryReader, BinaryWriter

s1 = new FileStream(path1, FileMode.Open, FileAccess.Read); s2 = new FileStream(path2, FileMode.Crea....
Category: C# Date: 10/14/2010 8:00:46 PM
C# : How do you sum all elements from a List<int> data

How do you sum all elements from a List data

int result = data.Sum();
Category: C# Date: 10/14/2010 7:08:47 PM
C# : What will be result of this code:
class C1 
{ protected int A = 0;
  public virtual void B() { console.writeLine(A); }}
class C2 : C1 {public override void B() { Console.WriteLine(A+10); }}
static void Main(string[] args)
{
C1 c = new C2();
c.B();
}
2 3 4 5 6 7 8 9 10 >>
Recent Answers
How do you declare destructor in c#?
kumar answered: by implementing finalize and dispose method