C#

What is the difference between const and static read-only?

What is the difference between const and static read-only? 
The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer).
-- in the static constructor (instance constructors if it's not static). 
More interview questions and answers

what is partial class in .net 2.0

Single Class can be separated into multiple physical files with same logical name.

I want to delete an dll with a newer version, but nothing it throws an UnauthorizedAccessException! please help!!! Assembly a = Assembly.LoadFile(source); Assembly b = Assembly.LoadFile(des

a

What is server code and client code in C#?

Code which execute on client are called client side code Otherwise Server side code.

Why we using in header file using system and more header file is in C# what is difference between and all header file ?

Give Real life examples of polymorphisms, encapsulation and inheritance?

real lif example of inheritance is parent child relationship

What is partial class?what is its advantage.

Partial Class:

  when a class need to be implemented at multiple locations with same class name then those classes need to be declared as "partial".

Example:

public main()
{
    class Test
    {
       -------
       -------
    }

    class Test //error
    {
       -------
       -------
    }
}

public main()
{
    partial class Test
    {
       -------
       -------
    }

    partial class Test //correct 
    {
       -------
       -------
    }
}

What is the name of c#.net compiler?

csc

What is an object?

Object:-Object is the basic run time entity.

 The object type is based on System.Object in the .NET Framework. You can assign values of any type to variables of type object.

All data types, predefined and user-defined, inherit from the System.Object class. The object data type is the type to and from which objects are boxed.

Exapmle:-
        class a
{}
public static void Main()
{
a ob= new a();// create object ob of class a;
}

What is a class?

Class:-
        Classes are declared using the keyword class. The declaration takes the form:

[attributes] [modifiers] class identifier [:base-list] { class-body }[;]
where: 

attributes (Optional) 
:-Additional declarative information.  
modifiers (Optional):-
The allowed modifiers are new, abstract, sealed, and the four access modifiers. 
identifier:- 
The class name. 
base-list (Optional) 
:-A list that contains the one base class and any implemented interfaces, all separated by commas. 
class-body 
:-Declarations of the class members. 

Example:-
   Public class a
{
// some members and parameter

}

what abstraction,encapsulation,inheritance? Define with example.

Abstraction:-Abstraction is the process of hiding the details and  exposing only the essential features of a particular concept or object.  
Abstraction is another good feature of OOPS. Abstraction means to show only the necessary details to the client of the object
Example:-A simple example is using a base class "Animal", with a virtual function "Walk". In the case two-legged versus four-legged animals, both of them walk, but the actual mechanics are different. The "Walk" method abstracts the actual mechanics behind the walking that each "Animal" does.
2nd example:-A class called Animal.
It has properties like ears,colour, eyes but they are not defined.
It has methods like Running(), Eating(), etc. but the method does not have any body, just the definition.

Encapsulation:-Encapsulation is the term given to the process of hiding all the details of an object that do not contribute to its essential characteristics.its wrapping of data and members in a single unit.Encapsulation is a process of hiding all the internal details of an object from the outside world .
1:- Encapsulation is the ability to hide its data and methods from outside the world and only expose data and methods that are required .
2.Encapsulation gives us maintainability, flexibility and extensibility to our code. 
3.Encapsulation provides a way to protect data from accidental corruption .
4.Encapsulation gives you the ability to validate the values before the object user change or obtain the value .
5.Encapsulation allows us to create a "black box" and protects an objects internal state from corruption by its clients.
6.Encapsulation is the technique or process of making the fields in a class private and providing access to the fields using public methods.

Example:-cars and owners...
all the functions of cars are encapsulated with the owners..
No one else can access it...
Inheritance:-In object-oriented programming (OOP), Inheritance is a way to compartmentalize and reuse code by creating collections of attributes and behaviors called objects which can be based on previously created objects. In classical inheritance where objects are defined by classes.
classes can inherit other classes. The new classes, known as Sub-classes (or derived classes), inherit attributes and behavior of the pre-existing classes, which are referred to as Super-classes.
the process of deriving one class from parent class called .
Example:-INHERITANCE MEANS A CHILD CLASS USE THE ALL THE ELEMENTS IN THE PARENTS CLASS.

DAD
|
CHILED
Seccond Example:-
Kingfisher jet
^
|
Airplane
^
|
Flying Things


What is mean "Death of Diamod"?

Death Diamond:-In object-oriented programming languages with multiple inheritance and knowledge organization, the diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?
 For example a class Button may inherit from both classes Rectangle (for appearance) and Clickable (for functionality/input handling), and classes Rectangle and Clickable both inherit from the Object class. Now if the equals method is called for a Button object and there is no such method in the Button class but there is an overridden equals method in both Rectangle and Clickable, which method should be eventually called? ihis is called "Death of Diamond".

Ex:
Class a
{
}
class b: a
{}
class c: a   
{}
class d:b,c
{}
      It is called the "diamond problem" because of the example of the class inheritance  in this situation. In this example, class A is at the top, both B and C separately inherit to A, and D inherits both......                   

what is the main difference between delegate and an event in c#?

Delegate:-A delegate is basically a reference to a method. A delegate can be passed like any other variable. This allows the method to be called anonymously, without calling the method directly. 
 delegate declaration defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure.

The delegate declaration takes the form:

[attributes] [modifiers] delegate result-type identifier ([formal-parameters])
Event:-An event in one program can be made available to other programs that target the .NET runtime.
An event is a member that enables an object or class to provide notifications. Clients can attach executable code for events by supplying event handlers. Events are declared using event-declarations: 

event-declaration: 
event-field-declaration
event-property-declaration 
event-modifier: 
new
public
protected
internal
private
static 


Example:-
 public delegate void EventHandler(object sender, Event e);
public class Button: Control
{
   public event EventHandler Click;
   protected void OnClick(Event e) {
      if (Click != null) Click(this, e);
   }
   public void Reset() {
      Click = null;
   }
}

How to use Hash Table,ArrayList in c# ?Explain with example.

ArrayList:-Arraylist is a collection of objects(may be of different types).
Arraylist is very much similar to array but it can take values of different datatypes.
If you want to find something in a arraylist you have to go through each value in arraylist, theres no faster way out.ArrayList's size can be changed dynamically.

Items are added to the ArrayList with the Add() method.
example:-HOW TO ADD DATA IN ARRAYLIST:
    using System.Collections;

class Program
{
    static void Main()
    {
        //
        // Create an ArrayList and add three elements.
        //
        ArrayList list = new ArrayList();
        list.Add("One");
        list.Add("Two");
        list.Add("Three");
    }
}
EXAMPLE-Adding one ArrayList to second one

There are different ways to add one ArrayList to another, but the best way is using AddRange. Internally, AddRange uses the Array.Copy or CopyTo methods, which have better performance than some loops.

=== Program that uses Add and AddRange ===

using System;
using System.Collections;

class Program
{
    static void Main()
    {
        //
        // Create an ArrayList with two values.
        //
        ArrayList list = new ArrayList();
        list.Add(15);
        list.Add(17);
        //
        // Second ArrayList.
        //
        ArrayList list2 = new ArrayList();
        list2.Add(110);
        list2.Add(113);
        //
        // Add second ArrayList to first.
        //
        list.AddRange(list2);
        //
        // Display the values.
        //
        foreach (int i in list)
        {
            Console.WriteLine(i);
        }
    }
}

=== Output of the program ===

15
17
110
113
The ArrayList class provides the Count property, which is a virtual property. When you use Count, no counting is actually done; instead, a cached field value is returned

HASH TABLE:-Hashtable is also collection which takes a key corresponding to each values.
If you want to find something in a hashtable you dont have to go through each value in hashtable, instead search for key values and is faster.The Hashtable lets you quickly get an object out of the collection by using it's key.
The Hashtable object contains items in key/value pairs. The keys are used as indexes. We can search value by using their corresponding key. 
The data type of Hashtable is object and the default size of a Hashtable is 16.


Items are added to the Hashtable with the ADD()method.
Example-How to add data in hash table:--
Add method of Hashtable is used to add items to the hashtable. The method has index and value parameters. The following code adds three items to hashtable.

hshTable .Add("A1",  "Kamal");
hshTable .Add("A2",  "Aditya");
hshTable .Add("A3",  "Ashish");

Retrieving an Item Value from Hashtable

The following code returns the value of "Author1" key: 

string name = hshTable["A1"].ToString(); 

Removing Items from a Hashtable

The Remove method removes an item from a Hashtable. The following code removes item with index "A1" from the hashtable: 

hshTable.Remove("A1");


           

Looking through all Items of a Hashtable

The following code loops through all items of a hashtable and reads the values. 

// Loop through all items of a Hashtable
IDictionaryEnumerator en = hshTable.GetEnumerator();
while (en.MoveNext())
{
      string str = en.Value.ToString(); 
}

What is the difference between shadow and override ?

Difference between shadow and override:-
  Shadowing hide the inherrited method using new keyword and CLR choose the target mthod between the parent and child  to call using the object's runtime type.Overriding hide the inherrited method using override keyword and the parent should be virtual. overrding always choose the object's compile-time type.

Differences:-
1-PorPose:-
SHADOW-Protecting against a subsequent base class modification introducing a member you have already defined in your derived class.
OVERRIDE-Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence

2-Redefined element:-
SHADOW:-Any declared element type.
OVERRIDE:-Only a procedure (Function or Sub) or property
3-Accessibility:-
SHADOW:-Any accessibility
OVERRIDE:-Cannot expand the accessibility of overridden element (for example cannot override Protected with Public)
4-Readability and writability
SHADOW:-Any combination
OVERRIDE:-Cannot change readability or writability of overridden property
5-Keyword usage
SHADOW:-Shadows recommended in derived class; Shadows assumed if neither Shadows nor Overrides specified.
OVERRIDE:-Overridable required in base class; Overrides required in derived class

What is the top .NET class that everything is derived from?

System.Object

When we can inherit a protected class-level variable?

Classes in the same namespace. 

Does C# support multiple inheritance?

No directly,but we can use  interface for multiple inheritence

How do you inherit from a class in C#?

Place a colon and then the name of the base class. 
exmple:-
       class a
{}
class b: a //inherit class a
{}

What is an abstract class?

Abstract class:-Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.

Abstract classes have the following features: 

1-An abstract class cannot be instantiated. 
2-An abstract class may contain abstract methods and accessors. 
3-It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited. 
4-A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors. 
Abstract class have complete and non complete member and methods.
Example:- abstract class a
{
int a;
public abstract void print();
}

What does the keyword virtual mean in the method definition?

It means that the subclasses( inheriting classes) can override the method.

How's method overriding different from overloading?

Difference between overriding and overloading:-
1:-When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class. 
2:-overriding keyword cahnge behavour in derive class with same signature 

Overloading means same name but passing different datatype or different number arguments within the same class

3:-Method overloading means same method name but different 
parameters. Method overriding means same method name and 
parameters also same. In method overloading method will 
differentiate with parameters name and in method overriding 
method will differentiate with method signature

Describe the accessibility modifier protected internal.

 protected internal:-Access is limited to the current project or types derived from the containing class.Access limited to the current project.

Are private class-level variables inherited?

 Yes, but they are not accessible

When you inherit a protected class-level variable? Who is it available to?

Protected members can be accessible by all the derived class irrespective of the Namespaces only protected Friend or protected internal will be accessed inside the namespace

What's the implicit name of the parameter that gets passed into the class' set method?

Value, and its datatype depends on whatever variable we're changing

Is it mandatory to implement all the methods which are there in abstract class if we inherit that abstract class?

yes,It is mandatory to implement all the methods which are there in abstract class if we inherit that abstract class?

What is the difference between const and static read-only?

The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case .
The Constant Fields are those which cannot be changed in runtime. Its value has to be assigned at declaration time. const string strMyString="Constant Data" ; //This is valid.Once declared now the value cannot be reassigned strMyString="Changed Data" ...

How to fill datalist usinf XML file and how to bind it,code behind language is c# ?

What is advantase of serialization?

SERIALIZATION:-serialization is the process of maintaing object in the form stream.it is useful in case of remoting.
2.Serialization is the process of converting object into byte stream which is useful to transport object(i.e remoting) persisting object(i.e files database)

3.SERIALIZATION IS PROCESS OF LODING THE OBJECT STATE IN THE FORM OF BYTE STREAMS IN DATABASE/FILE SYATEM.
4.Serialization in .NET allows the programmer to take an instance of an object and convert it into a format that is easily transmittable over the network or even stored in a database or file system. This object will actually be an instance of a custom type including any properties or fields you may have set
5.using Serialization instead of DataInput/DataOutput  streams has a major impact on versioning  .  Serialization keeps a lot  of metadata in the stream.  This makes detecting format changes very  easy, but can really complicate backward compatibility.Also,serialization is geared toward preserving the connections of an object
graph, which is behind a lot of the differences you mentioned.


How we handle sql exceptions?

SqlExceptionclass is created whenever the .NET Framework  Data Provider for SQL Server encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) SqlException always contains at least one instance of SqlError.

...

try
{
myCommand.Connection.Open();
}
catch (SqlException e)
{
string errorMessages ;

for (int i 0; i < e.Errors.Count; i++)
{
errorMessages + Index # + i + \n +
Message: + e.Errors[i].Message + \n +
LineNumber: + e.Errors[i].LineNumber + \n +
Source: + e.Errors[i].Source + \n +
Procedure: + e.Errors[i].Procedure + \n ;
}

System.Diagnostics.EventLog log new System.Diagnostics.EventLog();
log.Source My Application ;
log.WriteEntry(errorMessages);
Console.WriteLine( An exception occurred. Please contact your system administrator. );
}

What is the class that handles SqlServer exceptions?

SqlExceptionclass is created whenever the .NET Framework Data Provider for SQL Server encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) SqlException always contains at least one instance of SqlError.

What is indexer?

Indexer:-Indexers permit instances of a class or struct to be indexed in the same way as arrays. Indexers are similar to properties except that their accessor take parameters. 

Indexers allow you to index a class or a struct instance in the same way as an array. To declare an indexer, use the following declaration:

[attributes] [modifiers] indexer-declarator {accessor-declarations}
The indexer-declarator takes one of the forms:

type this [formal-index-parameter-list]
type interface-type.this [formal-index-parameter-list]
The formal-index-parameter takes the form:

[attributes] type identifier
where: 

attributes (Optional) :-
Additional declarative information. For more information on attributes and attribute classes,
modifiers (Optional) :-
Allowed modifiers are new and a valid combination of the four access modifiers. 
indexer-declarator :-
Includes the type of the element introduced by the indexer, this, and the formal-index-parameter-list. If the indexer is an explicit interface member implementation, the interface-type is included. 
formal-index-parameter-list:- 
Specifies the parameters of the indexer. The parameter includes optional attributes, the index type, and the index identifier. At least one parameter must be specified. The parameters out and ref are not allowed. 
accessor-declarations :-
The indexer accessors, which specify the executable statements associated with reading and writing indexer elements. 


The get Accessor:-
The get accessor body of an indexer is similar to a method body. It returns the type of the indexer. The get accessor uses the same formal-index-parameter-list as the indexer.
 For example:

get 
{
   return myArray[index];
}
The set Accessor:-
The set accessor body of an indexer is similar to a method body. It uses the same formal-index-parameter-list as the indexer, in addition to the value implicit parameter.
 For example:

set 
{
   myArray[index] = value;
}

where indexer is used ?

indexer member, which itself contains a get accessor and a set accessor. These accessors are implicitly used when you assign the class instance elements in the same way as you can assign elements in an array. The indexer provides a level of indirection where you can insert bounds-checking, and in this way you can improve reliability and simplicity with indexers.

Can we inherit the java class in C# class?If Yes then how?

yes,with the help of .dll of java class we can inherit the java class in c#

Every statement in C# must end with?

every statement in c sharp must end with semi colon.it indicates statement completed

The C# code files have an extension ?

C# code files have .cs exrension.

How you can compile a C# program using command promt?

We can compile a c# program using command promt
such as  :-csc filename

ASP.NET web pages can be programmed in C#?

yes. ASP .NET web pages can be programmed in C#

All the .NET languages have the following in common?

All the .NET languages have the following in common 1-Base class library

IL code compiles to ?

Il compiles to native code

Which is the first level of compilation in the .NET languages?

The first level of compilation in the .NET languages is source code convert into msil(Microsoft
Intermediate language code which is generated by the C# compiler  

What is IL?

IL:-stands for Intermediate Language.This is the language code generated by the C# compiler or any .NET-aware compiler. All .NET languages generate this code. This is the code that is executed during runtime.You can view this MSIL code with the help of a utility called Intermediate Language Disassembler (ILDASM). This utility displays the application's information in a tree-like fashion. Because the contents of this file are read-only, a programmer or anybody accessing these files cannot make any modifications to the output generated by the source code.

What is JIT?

What is CTS?

CTS:-CTS stands for Common Type System.
1-Common Type System is also a standard like cls. If two languages (c# or vb.net or j# or vc++) wants to communicate with each other, they have to convert into some common type (i.e in clr common language run time). In c# we use int which is converted to Int32 of CLR to communicate with vb.net which uses Integer or vice versa.
2-The Common Type System defines how types are declared, used, and managed in the runtime, and is also an important part of the runtime's support for cross-language integration.
3.The CTS makes available a common set of data types so that compiled code of one language could easily interoperate with compiled code of another language by understanding each others’ data types.

What is the namespace used for Reflection?

System.Reflection is used for Reflection

To access attributes, the waht is used?

List all collections in C#.

CSharp Collections are data structures that holds data in different ways for flexible operations . C# Collection classes are defined as part of the System.Collections or System.Collections.Generic namespace.
Most collection classes implement the same interfaces, and these interfaces may be inherited to create new collection classes that fit more specialized data storage needs.
collections are:-
1-C# ArrayList Class
2-Hash Table
3-Stack
4-Queue
etc

How you can write Unsafe code in C# and in which block?

Which method is used to force the garbage collector?

System.GC.Collect()

Each process in a 32 bit Windows environment has the what amount of virtual memory will available?

What is correct syntax for defining a delegate?

Correct syntax for defining a delegate:-
[attributes] [modifiers] delegate result-type identifier ([formal-parameters]);
where: 

attributes (Optional):-
Additional declarative information. For more information on attributes and attribute classes, 
modifiers (Optional) :-
The allowed modifiers are new and the four access modifiers. 
result-type :-
The result type, which matches the return type of the method. 
identifier :-
The delegate name. 
formal-parameters (Optional):- 
Parameter list. 
Example:-
  public delegate int delsum(int x,int y);

What is syntax of inherit a class?

Syntax of inherit a class:-
  Public class a
{
// some member and methods 
}
class b:a // b class inherit a class
{

} 

How do you deploy an assembly?

Assembly:-There are several ways to deploy an assembly into the global assembly
cache:

1) Use an installer designed to work with the global assembly cache.
This
is the preferred option for installing assemblies into the global assembly cache.
2) Use a developer tool called the Global Assembly Cache tool (Gacutil.exe)provided by the .NET Framework SDK.
3) Use Windows Explorer to drag and drop assemblies into the cache.

How namespace is used for globalization?

The System.Globalization namespace holds all culture and region classes to support different date formats, different number formats, and even different calendars that are represented in classes such as GregorianCalendar, HebrewCalendar, JapaneseCalendar, and so on. By using these classes, you can display different representations depending on the user’s locale.

How does a running application communicate or share data with other application running in different application domains?

If a running application does need to communicate or share data with other application running in different application domains,it must do by calling
by on .NETs Remoting Services 

What are difference between shadow and override?

We have an event handler called MyEvent and we want to link the click event of control, MyButton, to use MyEvent, what is the code that will like them together?

If we have an event handler called MyEvent and we want to link the click event of control, MyButton, to use MyEvent, Then code will be:-
control.Click += new EventHandler(MyEvent);

Which debugging window allows you to see the methods called in the order they were called?

The Call Stack window allows you to see the methods called in the order they were called.

The auto,local ,watch

The Call Stack window allows you to see all the name and values of all the variables in scope

What is wrapper class? Is it available in c#?

Wrapper class:-Wrapper class are those class in which we cant define and call all predefined functiuon.Wrapper Classes are the classes that wrap up the primitive  values in to a class that offer utility method to access it . For eg you can store list of int values in a vector class and access the class. Also the methods are static and hence you can use them without creating an instance . The values are immutable .

What is protected internal class in C# ?

Protected Internal:-Access is limited to the current project or types derived from the containing class.
2-The item is visible to any code within its containing assembly and also to any code inside a derived type

Which keyword is used of specify a class that cannot inherit by other class?

By using "Sealed " keyword

Can we create the instance for abstract classes?

NO,we cant create the instance for absract classes

Can we use Friend Classes or functions in C#?

no ,we can not use friend classes or function in c#

How we can use inheritance and polymorphisms in c# programming?

How to find exceptions in database?Give examples .

To find Exceptions in database:-Framework is endowed with provider specific exception class that 
we can use to handle exceptions from database.
For example instance to handle exceptions from sqlserver we can use System.Data.SqlClient.SqlException class.
             

How can objects be late bound in .NET?

Using Late Bound COM Objects

Where we can use DLL made in C#.Net?

Supporting .Net, because DLL made in C#.Net semi compiled version. It’s not a com object. It is used only in .Net Framework As it is to be compiled at runtime to byte code.

What Datatypes does the RangeValidator Control support?

There are following data types  that support Range validator control:-
1-Integer
2-Date
3-String
4-Double
5-Currency

Constructor is the method which is implicitly created when ever a class is instantiated. Why?

The default constructor is called automatically when ever a class is instantiated.

Why multiple Inheritance is not possible in C#?

multiple inheritance is possible through interface

Why strings are immutable?

In .NET, strings are immutable. This means that, once a value is assigned to a String object, it can never be changed.

This is a Regular expression built for parsing string in vb.net and passed to Regex class. Dim r As Regex = New Regex(",(?=([^""]*""[^""]*"")*(?![^""]*""))") What is C# equivalent for this regular exp

C# equivalent is :
System.Text.RegularExpressions.Regex myRegex new Regex (" ( ([^""]*""[^""]*"")*(?![^""]*""))");
 

How to convert ocx into DLL ?

use the aximp.exe provided with the .NET framework. 
It stands for Microsoft .NET ActiveX Control to Windows Forms Assembly Generator.
Generates a Windows Forms Control that wraps ActiveX controls defined in the OcxName.

What is the main difference between pointer and delegate with examples?

The difference between pointer and delegate:-
Delegate:-A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. Unlike function pointers in C or C++, delegates are object-oriented, type-safe, and secure. 
Example:-
   using System;
 
 delegate void MyDelegate(string s);
 
 class MyClass
 {
public static void Hello(string s)
  {
 Console.WriteLine("  Hello, {0}!", s);
  }
public static void Goodbye(string s)
  {
Console.WriteLine("  Goodbye, {0}!", s);
 }
public static void Main()
{
MyDelegate a, b, c, d;
a = new MyDelegate(Hello);
b = new MyDelegate(Goodbye);
 c = a + b;   // Compose two delegates to make another
d = c - a;   // Remove a from the composed delegate
Console.WriteLine("Invoking delegate a:");
a("A");
 Console.WriteLine("Invoking delegate b:");
 b("B");
Console.WriteLine("Invoking delegate c:");
c("C");
 Console.WriteLine("Invoking delegate d:");
 d("D");
  }
}
Output
Invoking delegate a:
  Hello, A!
Invoking delegate b:
  Goodbye, B!
Invoking delegate c:
  Hello, C!
  Goodbye, C!
Invoking delegate d:
  Goodbye, D!
Code Discussion
Pointer:-C# statements execute in either a safe or an unsafe context. Safe context is the default, but any code using pointers requires unsafe context.
unsafe:-   Specifies unsafe context. 
Once you have a pointer to a variable, you must ensure that the variable isn't moved in memory by the garbage collector.
pointer holds reference to a variable or pointer is a variable which holds the address of another variable.
Example:-
         using System;
class UnsafeTest 
{
   // unsafe method: takes pointer to int
   unsafe static void SquarePtrParam (int* p) 
   {
      *p *= *p;
   }

   public static void Main() 
   {
      int i = 5;
      // unsafe statement for address-of operator
      unsafe SquarePtrParam (&i);
      Console.WriteLine (i);
   }
}
Output
25

What is object pooling ?

Object pooling :- Object pooling is a COM+ Service that enables to reduce the overhead of creating each object from scratch, Object pooling is a well known technique to minimize the creation of objects that can take a significant amount of time. Common examples are to create a pool of database connections such that each request to the database can reuse an existing connection instead of creating one per client request.Threads are also another common candidate for pooling in order to increase responsiveness of an application to multiple concurrent client requests.

How do i read the information from web.config file?

connection cn=System.Configuration.ConfigurationManeger.Appsetting(variable name) in 2005

What is the default Function arguments?

C# does not support optional arguments.

What is XML Schema?

XML Schema:-The aim of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.XML Schema is an XML-based alternative to DTD.An XML schema describes the structure of an XML document.The XML Schema language is also referred to as XML Schema Definition (XSD).
XML Schema defines elements that can appear in a document. 
XML Schema defines attributes that can appear in a document 
XML Schema defines which elements are child elements 
XML Schema defines the order of child elements 
XML Schema defines the number of child elements 
XML Schema defines whether an element is empty or can include text 
XML Schema defines data types for elements and attributes.
XML Schema defines default and fixed values for elements and attributes 

How can we check whether a dataset is empty or not in C#.net

To check whether a dataset is empty or not in C#.net:- 

bool IsEmpty(DataSet dataSet) 
{ 
    foreach(DataTable table in dataSet.Tables) 
        if (table.Rows.Count != 0) return false; 
 
    return true; 
} 

Is it possible to inherit a class that has only private constructor?

No,Its not  possible to inherit a class that has only private constructor.

How do you choose 1 entry point when C# project has more Main( ) method?

If project has more  Main()method:-
CSC /main:classname filename.cs

What is C# reserved keyword ?Give List.

Keyword:-C# has a number of built in keywords.
Keywords are predefined reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix.
List of Reserved Keyword:-

abstract, enum ,long, stackalloc ,
as, event ,namespace ,static, 
base ,explicit, new, string, 
bool, extern ,null, struct, 
break ,false ,object, switch, 
byte, finally, operator, this, 
case, fixed, out, throw, 
catch, float, override ,true 
char ,for, params ,try ,
checked ,foreach, private, typeof, 
class, goto ,protected ,uint, 
const, if, public ,ulong, 
continue, implicit ,readonly, unchecked, 
decimal ,in ,ref, unsafe ,
default, int ,return ,ushort, 
delegate ,interface ,sbyte, using 
do, internal, sealed ,virtual 
double ,is, short, void 
else ,lock ,sizeof, while 

Sealed class can be inherited ?Yes/No

NO,Sealed classes cant be inherited

It is not permitted to declare modifier on the members in an interface definition?

yes.It is not permitted to declare modifier on the members in an interface definition. By default all the members in an Interface definition are public so there is no need to declare access modifier public. It would be a compile time error otherwise

How Interface members can be declare ?

Interface:-The interface keyword declares a reference type that has abstract members. The interface declaration takes the form:

[attributes] [modifiers] interface identifier [:base-list] {interface-body}[;]
where: 

attributes (Optional):- 
Additional declarative information. 
modifiers (Optional) :-
The allowed modifiers are new and the four access modifiers. 
identifier :-
The interface name. 
base-list (Optional) :-
A list that contains one or more explicit base interfaces separated by commas. 
interface-body :-
Declarations of the interface members. 

example:-
        public interface A

    {

        void show(string s);

    }
 public interface b

    {

        void get(string s);

    }
class d: a,b
{
}
 

Which method is implicitly called when an object is created ?

constructor will call when an object is created

Constructors can not be static?Yes/NO

NO,Constructors can be static.

Which preprocessor directive are used to mark that contain block of code is to be treated as a single block?

How are the attributes specified in C# ?

Attributes:-Attributes are elements that allow you to add declarative information to your programs. This declarative information is used for various purposes during runtime and can be used at design time by application development tools.
Attributes are generally applied physically in front of type and type member declarations. They're declared with square brackets, "[" and "]", surrounding the attribute such as the following ObsoleteAttribute attribute: 

For performing repeated modification on string which class is preferred?

String.Builder

In order to use stringbuilder in our class we need to refer??

using System.Text;

Gives the a member of stringbuilder.

Which method is actually called ultimately when Console.WriteLine( ) is invoked?

AppendFormat() method is actually called ultimately when Console.WriteLine( ) is invoked? 

What happens when you create an arraylist as ArrayList Arr=new ArrayList()?

when you create an arraylist as ArrayList Arr=new ArrayList() then an arraylist of object Arr is created with the capacity of 16

What is the output of Vectors.RemoveAt(1)?

The output of Vectors.RemoveAt(1):-Removes the object at position 1

GetEnumerator( ) of Ienumerable interface returns ?

GetEnumerator( ) of Ienumerable interface Returns an enumerator that iterates through a collection.

How do you add objects to hashtable in c#?

With the help of ADD()method we can add objects to hashtablein c#

If A.equals(B) is true then A.getHashcode & B.getHashCode must always return same hash code in c#?

Flase because it is given that A.equals(B) returns true i.e. objects are equal and now its hashCode is asked which is always independent of the fact that whether objects are equal or not. So, GetHashCode for both of the objects returns different value. 

The assembly class is defined in??

 The assembly class is defined inSystem.Reflection.

What is the first step to do anything with assembly??

It forms a security boundary and then reference boundary

How do you load assembly to running process ??

By using  Assembly.Load( )and Assembly.LoadFrom( )
we can loadssembly to running process

Assemblies cannot be loaded side by side??

True.Assemblies cannot be loaded side by side.

Where Application Isolation is assured using ??

Application Isolation is assured using:- Load assembly to running process 

Where does the version dependencies recorded ?

ApplicationDomain

How do you refer parent classes in C# ?

base keyword is used

Which attribute you generally find on top of main method ??

STAthread stands for Single Thread Application

How do you make a class not instantiable??

We can make a class not instantiable by making abstract class.

In a multilevel hierarchy how are the constructors are called ??

Which utility is used to create resource file ??

What is the extension of a resource file??

Resgen.exe 

A shared assembly must have a strong name to uniquely identify the assembly??

Where Public policy applies in C#??

Stream object can not be initialized?T/F

What is base class of stream??

System.IO

Which class use to Read/Write data to memory in C#

File Strem and Memory Sream

To Configure .Net for JIT activation what do you do ??

Which method is used by COM+ to ascertain whether class can be pooled??

How do you import Activex component in to .NET ??

.Net Remoting doesn't allow creating stateless & stateful Remote objects?Explain.

Windows services created by C# app run only?Yes/No?How?

The C# keyword int maps to which .NET type

What is an indexer in C#

How to implement multiple inheritence in C# ?

What is the use of fixed statement?

Can static methods be overridable?

In C# a technique used to stream the data is known as??

What is the order of destructors called in a polymorphism hierarchy ??

How can you sort the elements of the array in descending order??

Is it possible to Override Private Virtual methods?

NO,Its not possible to override private virtual method

What does the volatile modifier do?

What is the C# equivalent of System.Single?

How you can implement a single line comments ??

with the help of // we can single line comments

Code running under the control of CLR is often referred as

When and how Platform specific code is obtained ??

Explain How ?Intermediate Language also facilitates language interoperability.

What are the important features of IL?

NET interfaces are not derived from IUnknown & they do not have associated GUID's?

in which of the languages Code written in C# can not used .

Is it possible to debug the class written in other .Net languages in a C# project.

yes.It is possible to debug the class written in other .net language in a c# project.since .net can combine code written in several .net languages into one single assembly. Same is true with debugging.

What is a subclass of Value Type class??

What is a subclass of reference type ??

Which is .NET s answer to Memory Management??

.NET run time relies on the object reference counts to manage memory?

What are Namespaces?

Gives keywords is used along with Main function in C# ?

What are basic need to have an entry point of an apllication??

What does Main method returns in C# ?

Main method returns both type.int and void

What happens if we refer a variable which in not initialized in C# ?

Where Instantiating a reference object requires the use ??

Which of the member is not a member of Object?

Which of the escape sequence is used for Backspace?

If you need your own implementation of Equals method of object what needs ?

The condition for If statement in C# is enclosed with in??

For Each statement implicitly implements which interface?

Which modifiers hides an inherited method with same signature??

How we can get the capacity of an array in C#?

Array declaration in C# is done with??

Which operator is used for TypeCasting??

If we need to compare X to a value 3 how do we do it in C#?

What is equivalent valie of X=X+1??

How do you make CLR enforce overflow checking ?

How do you check whether an Object is compatible with Specific Type ?

How do you determine the size required by a Value type on the stack??

Which of these operator has the Highest Precedence??

Which of the following explicit type conversion is achieved with out loosing the original data value??

What happens when a C# project has more than one Main methods??

The field variables in a class or a struct in C# are by default given a value of zero ??

What is true about readonly variable in C# code?

What is JIT?

How you can explain char in c#?

How you can explain int in C#?

How you can explain struct in C#??

What is type of a class type in C# .Is It a value type?

What mean of bool data type in C#??

How you can explain String ???

Which are predefined reference types in C#? Give all.

What is similar in concept to IL?

Does C# support multiple inheritance?

What are the features of .NET ?

Which are used to denote comments in C#?

Can an assembly be stored across multiple files?

Does 'finally' keyword is supported in C#?

Which tool is used to browse the classes, structs, interfaces etc. in the BCL?

WinCV

How you can start a Thread in C#?

IF a namespace isn't supplied then which namespace does a class belong to System?

Does a base class Arrray belongs to the mamespace?

What is use of Namespaces?

can be more than 1 Main() functions in a C# program?

Does C# collection allows accessing an element using a unique key?

Does finally block will execute? Even if an exception hasn't occurred.

yes

How we can inherit multiple interfaces in C#

How Interfaces provide implementation of methods ?Explain with a example.

Does Structs and classes support inheritance ?

Which class can't be instantiated?

What is a multicast delegate?

Can we override a virtual method ?

Does Method Overloading and Overriding are same?

To change the value of a variable while debugging , What you need to do?

Are there some features of C# language not supported by .NET?If yes List features.

How we can call COM objects in C# ?

A delegate in C# is similar to what?

How Events are implemented in C# ?

Which language is more suitable for writing extremely high performance mission critical applications?

Can we use pointers in C#?

What is Boxing?

What is automatic memory management in .NET?

Value Types are stored on the heap?Yes/No

Reference types are stored in?Heap/Stack/....