C#.net interview questions and answers

          

csharp/c#.net interview questions and answers


C# interview questions - posted on March 26, 2014 at 03:05 PM by Nihal Singh

Q1.Suppose that you have an interface named IMyinterface in which four methods are available namedmethod1 (), method2 (), method3 (), method4 () and there are two classes named Base and Derived. As a c# developer you have to implement method1 () and method2 () in class Base and remaining two in Derived. How will you do that give example?

There is basic rule of interface that if any class implements the interface, that class should provide the definition of all the method of interface.But for solving the above scenario if we declare one class as abstract class then it is possible. Here is the example.
using System;

namespace CareerRideTest
{
interface IMyinterface
{
void method1();
void method2();
void method3();
void method4();

}
abstract class Base : IMyinterface
{
public void method1()
{
Console.WriteLine("method1");
}
public void method2()
{
Console.WriteLine("method2");
}
public abstract void method3();
public abstract void method4();
}
class Derived : Base
{
public override void method3()
{
Console.WriteLine("method3");
}
public override void method4()
{
Console.WriteLine("method4");
}
}
class MainClass
{

static void Main(string[] args)
{
Derived obj = new Derived();
obj.method1();
obj.method2();
obj.method3();
obj.method4();
Console.ReadKey();
}
}
}



Output
method1
method2
method3
method4

Q2.Trace the output for the following program.

using System;

namespace CareerRideTest
{

private class Demo
{
public void show()
{
Console.WriteLine("Access Modifiers");
}
}

class MainClass
{

static void Main(string[] args)
{
Demo obj = new Demo();
obj.show();
Console.ReadKey();
}
}
}


Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal. In a namespace class can be declared as public or internal. By default class access specifier is internal.

Q.3Trace the output for the following program.

using System;

namespace CareerRideTest
{

class A
{

public A()
{
Console.WriteLine("I am in A");
}
}
class B : A
{
public B()
{
Console.WriteLine("I am in B");
}
}
class C : B
{
static C()
{
Console.WriteLine("I am in Static C");
}
public C()
{
Console.WriteLine("I am in C");
}
}


class MainClass
{
static void Main(string[] args)
{
C obj = new C();

Console.ReadKey();

}
}

}


Output

I am in Static C
I am in A
I am in B
I am in C

Description: Constructors are always executed from base class to derived class, but if the constructor is static then it executes first when the class is loaded in the memory. Always remember that if all the constructor are static then it executes from derived class to base class or bottom to top otherwise it will executes from base class to derived class.

Q.4Trace the output for the following program.

using System;

namespace CareerRideTest
{

class A
{

static A()
{
Console.WriteLine("I am in A");
}
}

class MainClass
{
static void Main(string[] args)
{
A obj = new A();

Console.ReadKey();

}
}

}



Ans.This program will not compile. It will give error: access modifiers are not allowed on static constructors. So always remember that you cannot provide access modifiers on static constructors.

Q.5 Suppose that you have two interface named IFirstInterface and ISecondInterface.In both the interface same name method SameMethod() is available .As a developer you have to implement SameMethod() separately . How will you do that give example?

using System;
namespace CareerRideTest
{
public interface IFirstInterface
{
void SameMethod();
}

public interface ISecondInterface
{
void SameMethod();
}
class A : IFirstInterface, ISecondInterface
{
public A()
{
Console.WriteLine("I am in class A constructor ");
}

void IFirstInterface.SameMethod()
{
Console.WriteLine("I am in FirstInterface");
}
void ISecondInterface.SameMethod()
{
Console.WriteLine("I am in SecondInterface");
}
}

class MainClass
{
static void Main(string[] args)
{
IFirstInterface objFirst = new A();
objFirst.SameMethod();

ISecondInterface objSecond = new A();
objSecond.SameMethod();
Console.ReadKey();

}
}
}

Output:
I am in class A constructor
I am in FirstInterface
I am in class A constructor
I am in SecondInterface

Note:You cannot write as A objFirst = new A ();
in above program it will give error:

Q.6 Describe delegate in detail.

A delegate is an object that can refer to a method. It means that it can hold a reference to a method. The method can be called through this reference or we can say that a delegate can invoke the method to which it refers. The same delegate can be used to call different methods during the runtime of a program by simply changing the method to which the delegate refers. The main advantage of a delegate is that it invokes the method at run time rather than compile time. Delegate in C# is similar to a function pointer in C/C++.
A delegate type is declared using the keyword delegate. The prototype of a delegate declaration is given below:

delegate ret-type name(parameter-list);


Important Note:A delegate can call only those methods that have same signature and return type as delegate.
Example:
delegate string StrDemo(string str);
This delegate can only call those methods that have string return type and take argument as string.


Example on Delegate.
using System;
// Declare a delegate type.
namespace Test
{
delegate string StrDemo(string str);
class DelegateDemo
{
// Replaces spaces with **.
public string ReplaceSpaces(string s)
{
Console.WriteLine("Replacing spaces with *.");
return s.Replace(' ', '*');
}
// Remove spaces.
public string RemoveSpaces(string s)
{
string temp = "";
int i;
Console.WriteLine("Removing spaces.");
for (i = 0; i < s.Length; i++)
if (s[i] != ' ') temp += s[i];
return temp;
}


}
class MyClass
{
static void Main()
{
DelegateDemo obj = new DelegateDemo();
StrDemo strOp = new StrDemo(obj.ReplaceSpaces);
string str;
str = strOp("This is a test.");
Console.WriteLine("Resulting string: " + str);
Console.WriteLine();
strOp = new StrDemo(obj.RemoveSpaces);
str = strOp("This is a test.");
Console.WriteLine("Resulting string: " + str);
Console.WriteLine();

Console.ReadLine();
}
}
}

Output:

Replacing spaces with *.
Resulting string: This*is*a*test.
Removing spaces.
Resulting string: Thisisatest.

Q.7 Describe Anonymous functions in detail.

Ans: Anonymous means no name. An anonymous function is, an unnamed block of code that is passed to a delegate constructor. One advantage of using an anonymous function is that there is no need to declare a separate method whose only purpose is to be passed to a delegate. An anonymous method is created by following the keyword delegate with a block of code.
Example:
using System;

namespace Test
{
delegate void AnonymousDemo();
class Demo
{
static void Main()
{

AnonymousDemo DelObj = delegate
{
// This is the block of code passed to the delegate.

Console.WriteLine("Hello anonymous method");
}; // notice the semicolon
DelObj();
}
}
}

Q.8 Describe Lambda Expressions in brief.

Ans. An anonymous function can be created in another way that is called Lambda Expressions. The lambda expression provides a powerful alternative to the anonymous method.

The Lambda Operator

All lambda expressions use the new lambda operator, which is denoted by the symbol =>. This operator divides a lambda expression into two parts. On the left the input parameter (or parameters) is specified. Right hand side is the body of the lambda. The => operator is sometimes pronounced as “goes to” or “becomes.” There are two types of lambda expression in C#. What type of lambda expression is created, it is determines by the lambda body. The two types are

• Expression lambda
• Statement lambda

An expression lambda contains single expression. In this case, the body is not enclosed between braces. Statement lambda contains block of statements enclosed by braces. A statement lambda can contain multiple statements and include loops, method calls, and if statements.

Example:
using System;
namespace Test
{
delegate int Increment(int n);
// a delegate that takes an int argument

class SimpleLambdaDemo
{
static void Main()
{
// Create an Increment delegate instance that refers to
// a lambda expression that increases its parameter by 3.
Increment incr = count => count + 3;
// Now, use the incr lambda expression.
Console.WriteLine("Use increment lambda expression: ");
int x = 10;
while (x <= 20)
{
Console.Write(x + " ");
x = incr(x); // increase x by 3
}
Console.WriteLine("\n");

}
}
}

Q.9 Describe Event in .Net.

Ans.It is an important feature of C# that is based upon delegate. An Event is a message sent by an object such as control (Button, Checkbox, Radio button,etc.) or other part of the user interface, that the program responds to by executing code. It is an automatic notification that some action has occurred.
Events are members of a class and are declared using the eventkeyword. The general prototype of an event declaration

event event-delegate event-name;

Example:

using System;
namespace Test
{
// Declare a delegate type for an event.
delegate void MyEventHandler();
// Declare a class that contains an event.
class MyEvent
{
public event MyEventHandler SomeEvent;
// This is called to fire the event.
public void OnSomeEvent()
{
if (SomeEvent != null)
SomeEvent();
}
}
class EventDemo
{
// An event handler.
static void MyHandler()
{
Console.WriteLine("Event occurred");
}
static void Main()
{
MyEvent evt = new MyEvent();
// Add MyHandler() to the event list.
evt.SomeEvent += MyHandler;
// Fire the event.
evt.OnSomeEvent();
}
}
}

Q.10 Describe multicast event handling with example.

Ans

using System;
namespace Test
{
// Declare a delegate type for an event.
delegate void MyEventHandler();
// Declare a class that contains an event.
class MyEvent
{
public event MyEventHandler SomeEvent;
// This is called to fire the event.
public void OnSomeEvent()
{
if (SomeEvent != null)
SomeEvent();
}
}
class ButtonClass
{
public void Buttonhandler()
{
Console.WriteLine("Event received by button object");
}
}
class CheckBoxClass
{
public void Chkhandler()
{
Console.WriteLine("Event received by checkbox object");
}
}
class EventDemo
{
static void Handler()
{
Console.WriteLine("Event received by EventDemo");
}
static void Main()
{
MyEvent evt = new MyEvent();
ButtonClass btnObj = new ButtonClass();
CheckBoxClass chkObj = new CheckBoxClass();
// Add handlers to the event list.
evt.SomeEvent += Handler;
evt.SomeEvent += btnObj.Buttonhandler;
evt.SomeEvent += chkObj.Chkhandler;
// Fire the event.
evt.OnSomeEvent();
Console.WriteLine();
// Remove a handler.
evt.SomeEvent -= btnObj.Buttonhandler;
evt.OnSomeEvent();
}
}
}


Output:

Event received by EventDemo
Event received by button object
Event received by checkbox object

Event received by EventDemo
Event received by checkbox object

Important points regarding event.

Events can be specified in interfaces. Implementing classes must supply the event.
Events can be specified as abstract
An event can be specified as sealed.
An event can be virtual.

Q.11 Describe the collection framework.

Ans.The .NET supports several types of collections. All the collection classes are available in System. Collections and System.Collections.Specialized namespaces.

Sr.No Types of Collections Description
1. ArrayList The ArrayList collection is a simplest collection of unordered items.The Add and AddRangemethods of the ArrayListare used to add items.Add method takes object type as a parameter.
2. SortedList It is an dictionary object that gives you the sorted list of items.
3. Queue It uses the Enqueue method to add items to the queue and the Dequeuemethod to remove items from the list.It works on FIFO principle.
4. Stack It uses pop method to retrieves an item from the top of the stack and push method to add an item to the top of the stack. It works on LIFO principle.
5. Hashtable It is an dictionary object and works on key,valuepair.The add method takes two parameter the first one is key and the second one is value object. DictionaryEntry class is used to iterate all the items.HashTable is very efficient for large collection.
6. BitArray It is a resizeable collection that can store Boolean values. it supports bit-level operations such as and, not, or, and exclusive-or .
7. StringCollection It is same as ArrayList but can store only string values.
8. StringDictionary It is same as HashTable but can store only string key value pair.
9. ListDictionary It is very efficient for small collections of items
10. HybridDictionary It is the combination of HashTable and ListDictionary.If the no of items are less then it work as ListDictionary otherwise it works as HashTable.
11. NameValueCollection In this class you can store multiple values per key by using add method. For retrieving all the values for a particular key, you can use theGetValuesmethod.

Download C#.NET interview questions and answers

Test your C#.NET Skills

C#.NET (38 questions)
VB.NET (33 questions)
ASP.NET (41 questions)
.NET Framework (26 questions)
ADO.NET (10 questions)

C#.NET online test - 20 questions (NEW)

Next>>

Part 1 | Part 2 | Part 3 | Part 4 | part 5

C#.Net interview questions for freshers
What is the difference between Finalize() and Dispose()?

Latest answer: Dispose() is called by as an indication for an object to release any unmanaged resources it has held...........
Read answer

How does the XmlSerializer work? What ACL permissions does a process using it require?

Latest answer: The XmlSerializer constructor generates a pair of classes derived from XmlSerializationReader and XmlSerializationWriter by analysis of the classes using reflection........
Read answer

What are circular references? Explain how garbage collection deals with circular references.

Latest answer: A circular reference is a run-around wherein the 2 or more resources are interdependent on each other rendering the entire chain of references to be unusable........
Read answer

Explain how to add controls dynamically to the form using C#.NET.

Latest answer: The following code can be called on some event like page load or onload of some image or even a user action like onclick.......
Read answer

What are Extender provider components? Explain how to use an extender provider in the project.

Latest answer: An extender provider is a component that provides properties to other components..........
Read answer

Describe the configuration files in .Net. What are different types of configuration files in .Net framework?

Latest answer: The Machine.Config file, which specifies the settings that are global to a particular machine.......
Read answer

Describe the accessibility modifier "protected internal".

Latest answer: The Protected Internal access modifier can be accessed by:.....
Read answer

What is the difference between Debug.Write and Trace.Write? When should each be used?

Latest answer: Debug.Write: Debug Mode, Release Mode (used while debuging a project).......
Read answer

Explain the use of virtual, sealed, override, and abstract.

Latest answer: The virtual keyword enables a class to be overridden. If it has to be prevented from being overridden, then the sealed keyword needs to be used.........
Read answer

What benefit do you get from using a Primary Interop Assembly (PIA)?

Latest answer: A primary interop assembly contains type definitions (as metadata) of types implemented with COM. Only a single PIA can exist, which needs to be signed with a strong name by the publisher of the COM type library............
Read answer

Explain the use of static members with example using C#.NET.

Latest answer: Static members are not associated with a particular instance of any class.
They need to be qualified with the class name to be called.............
Read answer

How to achieve polymorphism in C#?

Latest answer: Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces........
Read answer

What are implementation inheritance and interface inheritance?

Latest answer: Implementation inheritance is achieved when a class is derived from another class in such a way that it inherits all its members...........
Read answer

How to add a ReadOnly property in C#.NET?

Latest answer: Properties can be made read-only by having only a get accessor in the implementation........
Read answer

How to prevent a class from being inherited in C#.NET?

Latest answer: The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.............
Read answer

What are generics in C#.NET?

Latest answer: Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace............
Read answer

What is the use of GetCommandLineArgs() method in C#.NET?

Latest answer: With GetCommandLineArgs() method, the command line arguments can be accessed.
The value returned is an array of strings.............
Read answer

What is the use of System.Environment class in C#.NET?

Latest answer: The System.Environment class can be used to retrieve information like:.......
Read answer

What is the difference between const and readonly in C#.NET?

Latest answer: The read only can be modified by the class it is contained in. However, the const cannot be modified. It needs to be instantiated only at the compile time......... 
Read answer

Advantages of CLR procedure over T-SQL procedure

Latest answer: The use of the CLR procedure makes it possible to do the complex database operations without having an in-depth knowledge of T-SQL..........
Read answer

How does C#.NET Generics and C++ Templates compare?

Latest answer: C# generics and templates in C++ are more or less similar syntactically..........
Read answer

What is an object pool in .NET?

Latest answer: It is a list of ready to use objects. Whenever a new request comes in for creating an object, then the application is served from this pool. This reduces the overhead of creating an object over and over again.............
Read answer

Why is an object pool required?

Latest answer: The request for the creation of an object is served by allocating an object from the pool. This reduces the overhead of creating and re-creating objects each time an object creation is required.............
Read answer

How does object pooling and connection pooling differ?

Latest answer: In Object pooling, you can control the number of connections. In connection pooling, you can control the maximum number reached........
Read answer

Explain how to Implement an Object Pool in C#.NET.

Latest answer: using System;
using System.Collections;..........
Read answer

Describe the three major components that make up a Web Service.

Latest answer: SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)...........
Read answer

Explain with code sample how to Implement a Web Service in .NET.

Latest answer: C# generics are a simpler approach to parameterized types without the complexity of C++ templates In addition, C# does not attempt to provide all of the functionality that C++ templates provide...........
Read answer

What is ILDASM and Obfuscator in NET?

Latest answer: ILDASM (Intermediate Language Disassembler)
De-Compilation is the process of getting the source code from the assembly...........
Read answer

Explain how Obfuscator works in NET

Latest answer: Obfuscator simply renames all types and namespace etc to meaningless code making it non human readable. This diminishes the possibility of reverse engineering...........
Read answer

What is an Exception in .NET?

Latest answer: Exceptions are errors that occur during the runtime of a program.
The advantage of using exceptions is that the program doesn’t terminate due to the occurrence of the exception...........
Read answer

Explain how to Handle Exceptions in .NET 2.0.

Latest answer: Exceptions should never be handled by catching the general System.Exception errors, rather specific exceptions should be caught and handled....:......
Read answer

What are Custom Exceptions? Why do we need them?

Latest answer: Custom exception needs to derive from the System.Exception class. You can either derive directly from it or use an intermediate exception like SystemException or ApplicationException as base class...........
Read answer

What are delegates and why are they required?

Latest answer: Delegates are like type safe function pointers. We need delegates as they can be used to write much more generic functions which are type safe also............
Read answer

Explain how to implement Delegates in C#.NET.

Latest answer: Here is an implementation of a very simple delegate that accepts no parameters............
Read answer

CLR Triggers

Latest answer: A CLR trigger could be a Date Definition or Date Manipulation Language trigger or could be an AFTER or INSTEAD OF trigger.............
Read answer

Steps for creating CLR Trigger

Latest answer: Follow these steps to create a CLR trigger of DML (after) type to perform an insert action:.............
Read answer.

What is an assembly in .NET?

Latest answer: An assembly is the primary unit of a .NET application. It includes an assembly manifest................
Read answer

What is a Constructor? What is a Destructor?

Latest answer: It is the first method that are called on instantiation of a type. It provides way to set default values for data before the object is available for use................
Read answer

Define abstract class in C#.NET.

Latest answer: Abstract class cannot be instantiated. Same concept in C++ known as pure virtual method............
Read answer

What is serialization in .NET?

Latest answer: Serialization is a process of converting an object into a stream of bytes. .Net has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer............
Read answer

C#.Net support multiple inheritance, comment

Latest answer: No, but we can use interface instead................
Read answer

Can private virtual methods be overridden in C#.NET?

Latest answer: No, moreover, you cannot access private methods in inherited classes........
Read answer

Is is possible to force garbage collector to run?

Latest answer: Yes, we can force garbage collector to run using System.GC.Collect()..........
Read answer

What is the role of data provider in ADO.NET?

Latest answer: The .NET data provider layer resides between the application and the database. Its task is to take care of all their interactions.............
Read answer

Describe how a .Net application is compiled and executed.

Latest answer: From the source code, the compiler generates Microsoft Intermediate Language (MSIL) which is further used for the creation of an EXE or DLL. The CLR processes these at runtime. Thus, compiling is the process of generating this MSIL...........
Read answer

What is an Event? Define Delegate.

Latest answer: When an action is performed, this action is noticed by the computer application based on which the output is displayed...........
Read answer

Test your C#.NET knowledge with our multiple choice questions!

What is Language Integrated Query (LINQ)?

LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations..................

NET Mobile overview.

.NET Mobile is a platform for developing applications for mobile phones. It’s an extension to .NET Framework and is called Microsoft Mobile Internet Toolkit..................

 

Next>>

Part 1 | Part 2 | Part 3 | Part 4 | part 5

Write your comment - Share Knowledge and Experience

Discussion Board
Attributes in C#

An attribute is a declarative tag that is used to convey information to runtime about the behaviors of various elements like classes, methods, structures, enumerators, assemblies etc., in your program. You can add declarative information to a program by using an attribute. A declarative tag is depicted by square ([ ]) brackets placed above the element it is used for.
Attributes are used for adding metadata, such as compiler instruction and other information such as comments, description, methods and classes to a program. The .Net Framework provides two types of attributes: the pre-defined attributes and custom built attributes.
For learning more about c# you can refer this link
c# interview questions


MohitKumar 04-16-2014 01:11 AM

Interview FAQs on Interface in c#

Good collection of questions

find some specific questions here.

http://www.queryingsql.com/2013/10/interview-faq-on-interface-in-c.html


queryinngsql.com 10-29-2013 08:24 AM

c# Interview questions

Selected Interview questions http://net-informations.com/faq/net/interview-questions.htm c# interview questions

jerry


Jerry 09-11-2013 04:04 AM

About Interview-Questions and answers

The topic is helpful for me.But the way of presenting answer need to be changed.Because I
need to click on link to get complete answer.It is time waste and more.If you are trying to reduce the space you can use something like hiding and showing div or something like that. Right now it is difficult to use.

Dhanil Manuel 02-18-2013 02:16 AM

Really useful questions...

I have gone through the above questions.. those are really helpful.... I have seen a similar collection of interview questions at https://www.logicsmeet.com/forum/38554-.net-interview-questions-for-3-years-experience.aspx

thanks

Hariharan 05-16-2012 05:29 AM

More c# questions

This is really useful. Help me a lot for the preperation. The link below has very good C# Interview Questions By Topic for Junior and Senior Developers. http://www.venkatcsharpinterview.blogspot.com

Swapan 05-3-2012 10:30 AM

C#.NET Test

A new Csharp-NET test has been uploaded, check your score!

Find out where you stand. Click on the link below and take our placement practice test now!

Take test NOW!

No registration required, just practice and check your score!

Wish you good luck!

Thanks,
The CareerRide Team

Career 11-30-2011 02:19 AM

C#.NET Test

A new Csharp-NET test has been uploaded, check your score!

Find out where you stand. Click on the link below and take our placement practice test now!

http://www.careerride.com/test.aspx?type=Csharp.NET-4

No registration required, just practice and check your score!

Wish you good luck!

Thanks,
The CareerRide Team

Career 11-30-2011 02:18 AM

 

More interview questions on C#.NET

.NET Framework

  • Explain the features of .NET Framework
  • Describe the .Net framework architecture. Explain the components of .Net framework, i.e. Common Language Runtime, Common type system, Type safety, Manage code execution, Side-by-side execution
Common language runtime (CLR)
  • What is common language runtime? Explain the component of CLR, i.e. Class loader, MSIL, Code manager, Garbage collector, Security engine, Type checker, Thread support, Exception manager, Debug engine, COM marshaler, Base class library.
  • How the Common Language Runtime Works
Execution of .Net application
  • Explain how a .Net application is compiled and executed.
  • Explain the components to ensure secure execution of code, i.e. Assembly loader, code verifier, Just-in-compiler (JIT).
  • Explain the types of JIT compilers, i.e. Standard JIT, Pre JIT, Econo JIT.
Assembly
  • Define Assembly. Explain the role that they play in the .Net framework.
  • Describe the main components of an assembly, i.e. Manifest, Type Metadata, MSIL code and Resources
  • What are the features provided by assemblies?
  • How can we view content of an assembly?
  • What are the types of assemblies? Private and shared assembly
  • Describe the global assembly cache.
.Net Technologies
  • Explain the technologies of .NET Framework 3.0.
    - Windows Presentation Foundation (WPF)
    - Windows communication Foundation
    - Windows workflow Foundation
    - Windows Cardspace
Common Type system (CTS)
  • Explain C# CTS
  • Explain the collection of CTS types defined by .NET Framework, i.e. classes, structs, enums, interfaces, delegates
  • What are type categories defined by CTS? Explain them
  • Benefit of value types.
  • Value types vs. reference types
  • What are the type conversions in C#? Explain them
  • C# 3.0 includes a new feature called an implicitly typed variable. Explain it.
.Net base class library
  • What is .Net base class library?
  • Explain the difference between value types and reference types.
Configuration and security
  • Describe the configuration files in .Net. What are different types of configuration files in .Net framework? – Machine configuration, Machine .config file, Application configuration file, security configuration file.
Boxing and unboxing
  • .NET defines value types and reference types as two major groups of data types. What are they? Explain them with example.
  • Advantages amd Disadvantage of Boxing.
C# Methods
  • Depict code to show c# methods with explanation.
  • Explain the concept of ref and out parameters with an example.
  • C# supports the use of parameter arrays and params keyword. Explain with an example
  • Using C#.Net, create a new method using input and output parameters.
  • Third type of comment supported by C# is a documentation comment. What is that?
Access Level
  • Explain the difference between public, internal and private access levels.
  • Explain the use of static members with example using C#.NET
C# user defined data type
  • Define enum. Provide an example to explain it
  • Define struct. Provide an example to explain it
C# Array
  • Explain Single dimensional arrays. Show it in an example
  • Explain Multidimensional arrays. Show it in an example
  • Explain Jagged Array. Show it in an example
  • Show how to declare a 4 by 5, two-dimensional array of ints.
  • Show how to declare a jagged two-dimensional int array in which the first dimension is 5.
  • Show how to initialize a one-dimensional int array with the values 1 through 5.
C# Object oriented programming
  • What is an object?
  • Characteristics of an object, i.e. state, behavior, identity, responsibility
  • Explain the major pillar of object oriented system, i.e. Abstraction, Encapsulation and Inheritance
  • Explain polymorphism.
Forms
  • Explain the form methods that are used to control their lifetime. Form.Show, Form.ShowDialog, Form.Activate, Form.Hide, Form.Close.
  • What are method’s events? Explain each of them, i.e. load, activate/deactivate,closing,closed.
Controls and components
  • Explain how to set the control tab order in C#.Net.
  • What is docking and anchoring. Explain their use with controls.
  • Explain how to add controls dynamically to the form using C#.NET.
  • What are Extender provider components? Explain how to use an extender provider in the project.
  • Explain how to add a control to a form at runtime.
Menus
  • What are MainMenu components? Explain its role.
  • What is ContentMenu component?
  • Write code using C#.NET for the following
    Enable or disable a menu item.
    Create shortcut keys for menu item.
    Make menu items invisible.
    Add items to a menu.
    Clone a menu
C# class
  • What is a class?
  • What are data members and function members of a C# class?
  • What are the access modifiers of the members of a class? public, private, protected, internal and protected internal
  • What is a constructor?
  • Explain the features of constructors.
  • What is a destructor? Features of destructor.
  • What are indexers?
  • Properties vs. indexers
  • Static methods of class. Example
  • non-static methods of class - Example
  • Static vs. non static methods of a class
Method overloading
  • Define Method overloading. Provide an example and explain
  • Define Operator overloading. Provide an example and explain
  • What are operators that cannot be overloaded?
  • What are rules needs to be followed while overloading operators?
Exceptions
  • Define Exceptions.
  • Explain System.Exception class in C#.
  • Explain the categories of exceptions that exist under the base class Exception, i.e. SystemException class, ApplicationException.
  • Explain Exception handling in C# with an example.
  • Define some of the common Exception classes in C#.
Inheritance in C#
  • Define Inheritance. Provide an example to show implemantation of inheritance in C#.
  • What are the access specifiers in base class? i.e. private, public, protected, internal and protected internal
Polymorphism in C#
  • Define Polymorphism.
  • How do we achieve Polymorphism in C#? i.e. virtual function and inheritance
  • Define Shadowing in C#. Provide an example to show implemantation of Shadowing in C#
  • Sealed class. Provide an example to show implemantation of Sealed class in C#
  • Concrete class. Provide an example to show implemantation of Concrete class in C#
  • Abstract class. Provide an example to show implemantation of Abstract class in C#
  • Interface. Provide an example to show implemantation of Interface in C#
  • Features of interfaces.
  • Abstract class vs. interface
  • Cloning in C#.
  • Concept of shallow copy or a deep copy
C# collection
  • Define collections in C#.NET.
  • Explain the types of collections - Generic collection and non-generic collection.
  • Define collection interfaces.
  • Describe some of the collection interfaces
    IEnumeration interface
    IEnumerable
    IList
    IComparable
    IComparer
    IDictionary
  • Advantages and disadvantages of Generic and non-generic classes
C# Delegates
  • Define Delegates
  • Explain the types of Delegates - unicast delegates and multicast delegates
  • Explain the steps in defining and using delegates in C#.
  • Single vs. Multicast Delegates
  • What is Asynchronous Delegates? Provide an example to show implemantation of Asynchronous Delegates in C#
  • Define Events. Describe how to implemant of an Event in C#.
  • Explain with an example of working of Eventhandler Delegates
  • Covariance and contravariance are used to enhance the Delegate behavior. Explain it
C# garbage collector
  • Automatic memory management in .NET is done by Garbage Collector (GC). Explain
  • Brief explanation of some of the garbage collector's methods
    Collect()
    GetGeneration()
    MaxGeneration
    WaitForPendingFinalizers()
    ReRegisterForFinalize()
    SuppressFinalize
  • Explain implicit resource management using Finalize () method
  • Explain explicit resource management using Dispose method.
C# Reflection
  • Explain Reflection C#.
  • Define the situation in which Reflection is useful.
  • Can you explain how to use different classes in system.Reflection namespace to get the types defined in the assembly?
Input/Output in C#
  • Overview of the Stream based I/O in C#.
  • Explain the types of Streams.
  • Explain how to access files paths by using the Path class.
Serialization in C#
  • Define serialization and deserialization.
  • Describe how to serialize and deserialize obect by using BinaryFormatter and SoapFormatter class.
  • Describe how to Serialize and deserialize objects by using xmlSerializer class.
  • Explain the Types of Serialization.
XML in C#
  • What is XML? Characteristics of XML. Benefit of XML
  • What are the different components of XML and explain their usage.
  • Explain the core .Net XML classes.
  • Explaination with an example the uses of XMLReader and XMLwriter for accessinbg and writing XML data.
ADO.NET in C#
  • Features of ADO.NET
  • Explain the components that help in data access and data manipulation in ADO.NET - .Net data provider and Dataset
  • Explain different .NET data provider
    ODBC data provider
    OLEDb data provider
    Oracle data provider
    SQL Data Provider
  • Differentiate between connected and disconnected environment.
  • Describe how to connect to SQLServer database using connection object.
  • Describe how to create and use command object to query the database.
  • Describe how to use a DataReader object to read the data fetched from the database.
  • Describe how to call a stored procedure created in SQL server database to perform insert, update or delete operations.
C# COM interoperability
  • Managed and unmanaged code
  • CLR provides two mechanisms for interoperation with unmanaged code, i.e. Platform invocation services, COM interoperability. Explain them
  • COM components vs. .NET components.
C# Multithreading
  • Define multitasking and multi-threading
  • Explain different thread states in the life cycle of a thread
  • Write a simple multithreaded application
C# web services
  • What is a web services?
  • Features of web services
  • What are the building blocks of web services?
  • Define functionality of UDDI, DISCO, WSDL and SOAP.
  • Define a web method.
  • Write a simple code to create a simple web services
  • Explain the concept of SOAP
C# deploying .NET application
  • Describe deployment process in .NET
  • What are the deployment project templates provided by VS.NET?
  • Describe how to implement XCOPY deployment.
LINQ
  • What does LINQ stand for? In general terms, what is its purpose?
  • As it relates to LINQ, what interface must a data source implement?
  • What are the query keywords that begin query clauses?
  • What query keyword is used to filter a sequence? Use it to rewrite your answer to question 5 so that it returns only those MyData objects whose Height property is less than 100.
  • What query keyword orders a sequence? Using your answer for question 6, sort the results into descending order based on the Height property.
  • What query keyword groups the result of a query organized into sequences? (In other words, what keyword returns a sequence of sequences?) Show its general form.
  • What keyword joins two sequences? Show its general form in the context of a from clause.
  • When using select or group, what keyword creates a continuation?
  • What keyword creates a variable that holds a value?
  • Show how to create an instance of an anonymous type that has two string properties called Title and Author.
  • What is the lambda operator? A lambda expression is one form of anonymous function. True or False?
  • What is the query method that corresponds to the where keyword?
  • What is an extension method? How must the first parameter be declared?
  • Why are extension methods important to LINQ?


 
Interview questions
 
Home | Want a Job? Submit Key Skills | Employer login | My key skills | About us | Sitemap | Contact us