Вы находитесь на странице: 1из 31

1.

How many types of JIT compilers are available? There are Two types of JIT compilers. standard JIT compiler. EconoJIT compiler. 2.What are the different types of assemblies name them? Private Public/Shared Satellite assembly 3.What is GAC? What are the steps to be taken to pick up the latest version from GAC? This Global Assembly Cache(GAC) stores .NET assemblies to be shared by several applications on that computer.publisher policy file is the configuration file to redirect to different version 1. Create the publisher Policy assembly using the assembly linker 2. Add the publisher policy assembly to the GAC using GACutil tool Gacutil /i 3. During runtime CLR is looking into the publisher policy file and redirect the application to bind with new version assembly as specified inside the publisher policy.

4.How do we use different versions of private assemblies in same application without re-build? In Asseblyinfo file need specify assembly version. assembly: AssemblyVersion 5.Different methods of using a legacy COM component in .NET framework? 1. TLBIMP to create an Assembly from a COM component 2. Reference a COM component directly from .NET Editor 6.How do you implement SSL? 1. create certificate request [ =>Right click on the website (VD) =>Click Directory Security Tab and click Server Certificate => Type name of certificate , Organization name , server name location info, => Type the path need to save certificate information Submit certificate request. ] 7.What is ref parameter? What is out parameter? Ref Parameter: Used to pass a parameter as a reference so that the function called will set the value. This could be used to return more than 1 value by a function. e.g. public int AddMuliply( int a , int b, ref int c) { c = a*b; return ( a+b); } The above function, returns the addition of two numbers as well as computes the multiplication result and passes to the calling function. Out Parameter: Used to pass values from the aspx Code-behind to the aspx page. The difference is that for a ref parameter, you have to assign a value before you call the function, while for OUT parameter, you dont have to assign a value, the calling function assumes that the called function would assign some value. A ref parameter must first be initialized before being passed from the calling function to the called function. but a out parameter need not be initialized, we can pass it directly when we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different, Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out

parameter it is necessary to initialize. When to use out and ref parameter, out parameter is used when we want to return more than one value from a method. Ref parameter can be used as both input and o/p parameter out parameter can be used as only output parameter 8.What is boxing? What is the benefits and disadvantages? Boxing is converting a value-type to reference type. An example is converting an integer value to an object value. Ex: int intValue = 10; object obj = (object)intValue; This is used if you want to pass variables of object types to certain functions or methods you have created. Commonly used in events for example (Object sender...). 9.Why multiple Inheritance is not possible in C#? Multple inheritance is coneceptually wrong. It shouldn't be allowed in any language. Inheritance is the strongest relationship that can be expressed in OO languages. It's used to express IS-A relationship. Aggregation is used to express IS CONSTRUCTED IN TERMS OF. If you're using multiple inheritance in C++ then you're design is wrong and you probably want to use aggregation. On the other hand it's plausible to want to use multiple interfaces. For instance you might have a class wheel and a class engine. You could say that your class car inherits from wheel and from engine but that's wrong. In fact car aggregates wheel and engine because it is built in terms of those classes. If wheel is an interface and engine is an interface then car must inherit both of these interfaces since it must implement the functionaity of wheel and engine .On this basis we can see that multiple inheritance for classes should not be allowed because it promotes mis-use of the strong IS-A relationship. C# enforces the correct concepts whilst C++ allows mis-use. multiple interface inheritance is permissible and C# allows this. It's all to do with properly understanding OO concepts. Absolute Multiple Inheritance is not possible in c# but partially it supports multiple inheritance by the use of Interfaces. As interfaces force a class to implement same type of behaviour (as defined in interface) which classes implements that interface What is the top .NET class that everything is derived from? System.Objects What is an abstract class? The abstract modifier can be used with classes, methods, properties, indexers, and events. 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: An abstract class cannot be instantiated. An abstract class may contain abstract methods and accessors. It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited. A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors. Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation. Abstract methods have the following features: An abstract method is implicitly a virtual method. Abstract method declarations are only permitted in abstract classes. Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example: public abstract void MyMethod(); ________________________________________ abstract class is a prototype of a class. it is used to provide partial class implementation. abstract class contain abstract method which can be implemented by derived class. some rules for abstract class are following-: 1) an object of an abstract class can never be created. 2)you can not declare an abstract method outside the abstract class.

3)can not be declared sealed. WHAT IS THE ADVANTAGE OF SERIALIZATION? Serialization is the process of maintaing object in the form stream. it is useful in case of remoting. 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) SERIALIZATION IS PROCESS OF LOADING THE OBJECT STATE IN THE FORM OF BYTE STREAMS IN DATABASE/FILE SYATEM. Can we inherit the java class in C# class,how? Java Programming language is not supported with .Net Framework hence you cannot inherit javaclass in C# class.Also Java has JavaByte code after compiling similar to MSIL which is similar but cannot inherit due to framework support. Are C# destructors the same as C++ destructors? No. They look the same but they are very different. The C# destructor syntax (with the familiar ~ character) is just syntactic sugar for an override of the System.Object Finalize method. This Finalize method is called by the garbage collector when it determines that an object is no longer referenced, before it frees the memory associated with the object. So far this sounds like a C++ destructor. The difference is that the garbage collector makes no guarantees about when this procedure happens. Indeed, the algorithm employed by the CLR garbage collector means that it may be a long time after the application has finished with the object. This lack of certainty is often termed non-deterministic finalization, and it means that C# destructors are not suitable for releasing scarce resources such as database connections, file handles etc. To achieve deterministic destruction, a class must offer a method to be used for the purpose. The standard approach is for the class to implement the IDisposable interface. The user of the object must call the Dispose() method when it has finished with the object. C# offers the using construct to make this easier. What is wrapper class? is it available in c#? 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 . wrapper class are those class in which we can not define and call all predefined function .it is possible in java not C#. Which tool is used to browse the classes, structs, interfaces etc. in the BCL? wincv as in Windows Class View How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? The using() pattern is useful because it ensures that Dispose() will always be called when a disposable object (defined as one that implements IDisposable, and thus the Dispose() method) goes out of scope, even if it does so by an exception being thrown, and thus that resources are always released. What happens when a C# project has more than 1 Main methods f the project is compiled using /main switch with the compiler then the project compiles successfully. For example: class A { public static void Main(string[] args) { Console.WriteLine("Main in class A"); } } class B { public static void Main(string[] args) { Console.WriteLine("Main in class B"); } }

Now compile with the /main switch with the C# compiler like csc MultipleMain.cs /main:A This will compile without error and while executing it will show Main in class A Attempting to compile an application consisting of multiple classes with defined Main methods and not specifying the /main switch will result in a compiler error. How do you refer parent classes in C#? A) Super B) This C) Base This keyword is used for reffering current object and Base keyword is used for referring parrent class. so ans. is C. Super: Super is used to Refer the Base Class in JAVA This: This is used to Refer the Current or Child Class in C# Base: Base is used to Refer The Parent or Base Class What is object pooling Defination: A performance optimization based on using collections of pre-allocated resources, such as objects or database connections With the advent of the .NET platform, writing code that pools objects and threads has become a simple task. By using the Threading and Collections namespaces, you can create robust object pooling applications. This could also be done by implementing COM+ interop interfaces into your code. Which method is actually called ultimately when Console.WriteLine( ) is invoked? A) Append( ) B) AppendFormat( ) C) Tostring( ) Ans: B, AppendFormat() method is called. What is an Assembly? An assembly is a file that is automatically generated by the compiler upon successful compilation of every .NET application. It can be either a Dynamic Link Library or an executable file. It is generated only once for an application and upon each subsequent compilation the assembly gets updated. The entire process will run in the background of your application; there is no need for you to learn deeply about assemblies. However, a basic knowledge about this topic will help you to understand the architecture behind a .NET application. An assembly is used by the .NET CLR (Common Language Runtime) as the smallest unit for: deployment; version control; security; type grouping and code reuse. Assemblies consists of a manifest and one or more modules and/or files like HTML, XML, images, video clips,... An assembly can be thought of as a logical DLL and must contain a single manifest and may optionally contain type meta data, MSIL (Microsoft Intermediate Language) and resources. Assemblies come in 2 flavors: application private and shared. Application private assemblies are used by one application only. This is the default style of assembly. Such assemblies must reside in the application folder. Shared assemblies are meant to be used by more than one application. They must have a globally unique name and must be defined in the GAC (Global Assembly Cache). To learn more about viewing the GAC Basically there are two kind of assemblies when it comes to deployment. Private Assemblies Shared Assemblies Private assemblies are the ones which are in your application folder itself. They can be easily and uniquely identified by their name. These type of assemblies can be deployed simply by copying them to the bin folder of your application. Shared Assemblies are those which can be shared by multiple applications on the machine. For this we have to place the Shared assembly in the GAC. Now since we can install any application or assembly created by any company, that is we install assemblies from oracle, microsoft and similarly from many other companies.

There is always a possiblity that they may use the same assembly name as your assembly name. If such type of assemblies are placed in the GAC then we cannot uniquely identify a particular assembly.But if we give a strong name to the assmebly then it is like a unique identifier for the assembly.It is Globally unique. Strong name consists of 1. Name of the assembly 2. Public key token 3. optionally any resources 4. Version Number So basically to uniquely identify a particular assembly from the GAC we have to give it a strong name. Its that simple. The Shared assembly can be deployed in to GAC by using the GACUTIL tool with the -i switch gacutil -i assemblyname or simply copying it to the assembly folder in the windows directory (XP) or WINNT directory(others) Also there are Satellite Assemblies which contian only resources like strings, images etc. Also there are dynamic assemblies which are generated on the fly dynamically. What does the modifier protected internal in C# mean? The Protected Internal can be accessed by Members of the Assembly or the inheriting class, and of course, within the class itself. In VB.NET, the equivalent of protected internal is protected friend. The access of this modifier is limited to the current assembly or the types derived from the defining class in the current assembly. To know more on different types of access specifiers Can multiple data types be stored in System.Array? So whats an array all about? An array is a collection of items of the same type, that is grouped together and encompassed within an array object. The array object, or the System.Array object to be precise, is derived from the System.Object class. It is thus, stored in the form of a heap in the memory.

An array may be of single dimensional, multi-dimensional or jagged (a jagged array means an array within an array). A group of items when assigned values within braces implicitly derive from System.Array class. See example below written in C#... int[] testIntArray = new int[4] { 2, 3, 4, 5 }; Object[] testObjArray = new Object[5] { 32, 22, 23, 69, 75 }; Ideally an array should contain a single data type. But still in case there is a requirement to place data of different data types in a specific array, then in such a scenario, the data elements should be declared as an object type. When this is done, then each element may point ultimately to a different data type. See code example below written in VB.NET... Dim allTypes As Object() = New Object() {} 'In this kind of scenario, the performance may tend to slow down, as data conversions may take place. 'In case a value type is converted to reference type, then boxing and unboxing occurs 'To know more on Value Types & Reference Types, Click Here Dim studentTable(2) As Object studendTable(0) = "Vishal Khanna" studentTable(1) = 28 studentTable(2) = #9/1/1978# 'To get these values of these varying datatypes, their values are converted to their original data type Dim myAge As Integer = CInt(studentTable(1)) Dim myBirthDay as Date = CDate(studentTable(2)) How to sort array elements in descending order in C#? Elements of an array may not be sorted by default. To sort them in descending order, the Sort() method is first called. Next, to descend the order, call the Reverse() method

Whats the use of "throw" keyword in C#? The throw keyword is used to throw an exception programatically in C#. In .NET, there is an in-built technique to manage & throw exceptions. In C#, there are 3 keyword, that are used to implement the Exception Handling. These are the try, catch and finally keywords. In case an exception has to be implicitly thrown, then the throw keyword is used. See code example below, for throwing an exception programatically... class SomeClass { public static void Main() { try { throw new DivideByZeroException("Invalid Division Occured"); } catch(DivideByZeroException e) { Console.WriteLine("Exception - Divide by Zero" ); } } } Can we put multiple catch blocks in a single try statement in C#? Yes. Multiple catch blocks may be put in a try block. See code example below, to see multiple catch blocks being used in C#. class ClassA { public static void Main() { int y = 0; try { val = 100/y; Console.WriteLine("Line not executed"); } catch(DivideByZeroException ex) { Console.WriteLine("DivideByZeroException" ); } catch(Exception ex) { Console.WritLine("Some Exception" ); } finally { Console.WriteLine("This Finally Line gets executed always"); } Console.WriteLine("Result is {0}",val); } } How to achieve polymorphism in C#? In C#, polymorphism may be achieved by overloading a function, overloading an operator, changing the order of types, changing the types using the same name for the member in context. To see some code examples of polymorphism, Click Here. What is polymorphism? Polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). For example, a polymorphic function definition can replace several type-specific ones, and a single polymorphic operator can act in expressions of various types. Many programming languages implement some forms of polymorphism.

The concept of polymorphism applies to data types in addition to functions. A function that can evaluate to and be applied to values of different types is known as a polymorphic function. A data type that contains elements of different types is known as a polymorphic data type. Polymorphism may be achieved by overloading a function, overloading an operator, changing the order of types, changing the types using the same name for the member in context. Example: Public Class Calc { public void fnMultiply(int x, int y) { return x * y; } public void fnMultiply(int x, int y, int z) { return x * y * z; } } ... ... Calc obj; int Result; Result = obj.fnMultiply(2,3,4); // The second fnMultiply would be called Result = obj.fnMultiply(3,4); // The first fnMultiply would be called //Here, the call depends on the number of parameters passed, polymorphism is achieved using overloading How to add a ReadOnly property in C#? Property - A property is an entity that describes the features of an object. A property is a piece of data contained within a class that has an exposed interface for reading/writing. Looking at that definition, you might think you could declare a public variable in a class and call it a property. While this assumption is somewhat valid, the true technical term for a public variable in a class is a field. The key difference between a field and a property is in the inclusion of an interface. We make use of Get and Set keywords while working with properties. We prefix the variables used within this code block with an underscore. Value is a keyword, that holds the value which is being retrieved or set. See code below to set a property as ReadOnly. If a property does not have a set accessor, it becomes a ReadOnly property. public class ClassA { private int length = 0; public ClassA(int propVal) { length = propVal; } public int length { get { return length; } } } How to prevent a class from being inherited? Sealed in C#? In order to prevent a class in C# from being inherited, the sealed keyword is used. Thus a sealed class may not serve as a base class of any other class. It is also obvious that a sealed class cannot be an abstract class. Code below... sealed class ClassA { public int x; public int y; } No class can inherit from ClassA defined above. Instances of ClassA may be created and its members may then be accessed, but

nothing like the code below is possible... class DerivedClass: ClassA {} // Error Can we inherit multiple interfaces in C#? Yes. Multiple interfaces may be inherited in C#. Note that when a class and multiple interfaces are to be inherited, then the class name should be written first, followed by the names of the interfaces. See code example below, on how to inherit multiple interfaces in C#. class someclass : parentclass, IInterface1, IInterface2 { //...Some code in C# } What are the different ways of overloading methods in C#? What is function overloading in C#? Before knowing the different methods of overloading in C#, lets first clear out what exactly overloading is. Overloading is the OOPs concept of using a method or a class in different styles by modifying the signature of the parameters in it. To know more on overloading, Click Here. In order to achieve overloading, there may be several techniques applied. There are different types of overloading like Operator Overloading, Function Overloading etc. Function overloading may be achieved by changing the order of parameters in a function, by changing the types passed in the function, and also by changing the number of parameters passed in a function. See code sample below to see types of overloading. //Define a method below public void fnProcess(int x, double y) { ...... } //change the order of parameters public void fnProcess(double x, int y) { //.......Some code in C# } //Similarly, we may change the number of parameters in fnProcess //and alter its behaviour How to call a specific base constructor in C#? What is a Constructor? - It is a method that gets invoked when an instance of a class is created. In case a class has plenty of constructors, i.e. there are plenty of overloaded constructors, in such a scenario, it is still possible to invoke a specific base constructor. But there is a special way, as explicit calls to a base constructor is not possible in C#. See code below: public class dotnetClass { public dotnetClass() { // The constructor method here } // Write the class members here } //Sample code below shows how to overload a constructor public class dotnetClass { public dotnetClass() {

// This constructor is without a parameter // Constructor #1 } public dotnetClass(string name) { // This constructor has 1 parameter. // Constructor #2 } } This constructor gets executed when an object of this class is instantiated. This is possible in C#. Calling a specific constructor will depend on how many parameters, and what parameters match a specific constructor. Note that a compile time error may get generated when 2 constructors of the same signature are created. We may make use of the this keyword and invoke a constructor. See code example below. this("some dotnet string"); //This will call Constructor #2 above What is the use of the base keyword. Suppose we have a derived class named dotnetderivedclass. If this derived class is to invoke the constructor of a base class, we make use of the base keyword. See code example below on how to use a base keyword to invoke the base class constructor. public class dotnetClass { public dotnetClass() { // The 1st base class constructor defined here } public dotnetClass(string Name) { // The 2nd base class constructor defined here } } public class dotnetderivedclass : dotnetClass // A class is being inherited out here { public dotnetderivedclass() { // dotnetderivedclass 1st constructor defined here } public dotnetderivedclass(string name):base(name) { // dotnetderivedclass 2nd constructor defined here } } Note that we have used the base keyword in the sample code above. The sequence of execution of the constructors will be as follows: public dotnetClass() method -> public dotnetderivedclass() method The above sequence triggers when there is no initializer to the base class, and thus it triggers the parameterless base class constructor. The other base class constructor may also get invoked when we pass a parameter while defining it. What is a static constructor?

Static Constructor - It is a special type of constructor, introduced with C#. It gets called before the creation of the first object of a class(probably at the time of loading an assembly). See example below. Example: public class SomeClass() { static SomeClass() { //Static members may be accessed from here //Code for Initialization } } While creating a static constructor, a few things need to be kept in mind: * There is no access modifier require to define a static constructor * There may be only one static constructor in a class * The static constructor may not have any parameters * This constructor may only access the static members of the class * We may create more than one static constructor for a class Can a class be created without a constructor? No. In case we dont define the constructor, the class will access the no-argument constructor from its base class. The compiler will make this happen during compilation. What are generics in C#? Generics in C# is a new innovative feature through which classes and methods in C# may be designed in such a way that the rules of a type are not followed until it is declared. The generics feature in C# has been introduced with version 2.0 of the .NET Framework. Using generics, a class template may be declared that may follow any type as required at runtime. The class behavior is later governed by the type that we pass to the class. Once the type is passed, the class behaves depending on the type passed to this generic class. What is the use of the main() function in C#? Every executable C# application must contain a class defining a Main() method that signifies the entry point of the application. Note that the Main() method is of the access type public by nature. Moreover, it is also static. See example below: using System; class Question { public static int Main(string[] args) { Console.Writeline("Another Question"); Console.Readline(); return 0; } } A public member is accessible from other types. The main() method is set as static so that it may be invoked at class level itself, without the need of creating an instance of it. The single parameter is an array of strings. that may contain any number of incoming command line arguments. Can we set the specifier of the main() method in C# as private? Yes. When the access specifier is set as private for the Main() method, then other assemblies may not invoke this class' Main() method as the starting point of the application. The startup scope gets limited to the class in context itself. See code below: private static void Main() { //This code isn't invoked automatically by other assemblies } Can we set different types of parameters & return-types in main() method"?

Yes. The Main() method may easily be played around with by developers by passing different parameters and setting different return types. See the code below, that demonstrates different ways the Main() method may be implemented: (1) public static void Main(string[] args) { //NO return type, the argument is an array of strings } (2) public static int Main(string[] args) { //Return type is int, argument is an array of strings } (3) public static int Main() { //Return type is int, NO arguments } (4) public static void Main() { //Return type is void, NO arguments } What is the use of GetCommandLineArgs() method? The GetCommandLineArgs() method is used to access the command line arguments. The return value of this method is an array of strings. It is a method of the System.Environment class. See the code example below: public static int Main(string[] args) { string[] strArgs = System.Environment.GetCommandLineArgs(); Console.WriteLine("Arguments {0}", strArgs[0]); } What is the use of System.Environment class? The class System.Environment is used to retrieve information about the operating system. Some of the static members of this class are as follows: 1) Environment.OSVersion - Gets the version of the operating system 2) Environment.GetLogicalDrives() - method that returns the drives 3) Environment.Version - returns the .NET version running the application 4) Environment.MachineName - Gets name of the current machine 5) Environment.Newline - Gets the newline symbol for the environment 6) Environment.ProcessorCount - returns number of processors on current machine 7) Environment.SystemDirectory - returns complete path to the System Directory 8) Environment.UserName - returns name of the entity that invoked the application Why is the new keyword used for instantiating an object in .NET? The new keyword instructs the .NET compiler to instantiate a new object, with appropriate number of bytes (depending on the type) for the object and gather required memory from the managed heap. What are the default values for bool, int, double, string, char, reference-type variables? When the objects of the following types are declared, then they have a default value during declaration. The following table shows the default value for each type: Type Default Value bool false int 0

double 0 string null char '\0' Reference Type null How to declare a constant variable in C#? What is the use of the const keyword? If a variable needs to have a fixed value, that may not be changed across the application's life, then it may be declared with the const keyword. The value assigned to a constant variable (using the const keyword) must be known at the time of compilation In C#, can we create an object of reference type using const keyword? No. A constant member may not be created of an object that is of reference type, because its value is decided dynamically at runtime. What is the difference between const and readonly in C#? When using the const keyword to set a constant variable, the value needs to be set at compile time. The const keyword may not be used with an object of reference type. In case a reference type needs to be assigned a non-changeable value, it may be set as readonly What are the different parameter modifiers available in C#? What is a parameter modifier? Parameter modifiers in C# are entities that controls the behaviour of the arguments passed in a method. Following are the different parameter modifiers in C#: 1) None - if there is NO parameter modifier with an argument, it is passed by value, where the method recieves a copy of the original data. 2) out - argument is passed by reference. The argument marked with "out" modifier needs to be assigned a value within this function, otherwise a compiler error is returned. public void multiply(int a, int b, out int prod) { prod = a * b; } Here, note that prod is assigned a value. If not done so, then a compile time error is returned. 3) params- This modifier gives the permission to set a variable number of identical datatype arguments. Note that a method may have only one "params" modifier. The params modifier needs to be in the last argument. static int totalruns(params int[] runs) { int score = 0; for(int x=0; x &nsbp;score+=runs[x]; return score; } Further, from the calling function, we may pass the scores of each batsman as below... score = totalruns(12,36,0,5,83,25,26); 4) ref - The argument is given a value by the caller, where data is passed by reference. This value may optionally be reset in the called method. Note that even if NO value is set in the called method for the ref attribute, no compiler error is raised. What is the difference between out and ref in C#? 1) out parameters return compiler error if they are not assigned a value in the method. Not such with ref parameters. 2) out parameters need not be initialized before passing to the method, whereas ref parameters need to have an initial value before they are passed to a method. What is delay signing? Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or

assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development. Is there an equivalent of exit() for quitting a C# .NET application? Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it's a Windows Forms app. Can you prevent your class from being inherited and becoming a base class for some other classes? Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. I was trying to use an "out int" parameter in one of my functions. How should I declare the variable that I am passing to it? You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { } How do I make a DLL in C#? You need to use the /target:library compiler option. Is XML case-sensitive? Yes, so and are different elements. How do I simulate optional parameters to COM calls? You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters. Will finally block get executed if the exception had not occurred? Yes. What is the C# equivalent of C++ catch (), which was a catch-all statement for any possible exception? Does C# support trycatch-finally blocks? Yes. Try-catch-finally blocks are supported by the C# compiler. Here's an example of a try-catch-finally block: using System; public class TryTest { static void Main() { try { Console.WriteLine("In Try block"); throw new ArgumentException(); } catch(ArgumentException n1) { Console.WriteLine("Catch Block"); } finally { Console.WriteLine("Finally Block"); } } } Output: In Try Block

Catch Block Finally Block If I return out of a try/finally in C#, does the code in the finally-clause run? Yes. The code in the finally always runs. If you return out of the try block, or even if you do a "goto" out of the try, the finally block always runs, as shown in the following example: using System; class main { public static void Main() { try { Console.WriteLine("In Try block"); return; } finally { Console.WriteLine("In Finally block"); } } } Both "In Try block" and "In Finally block" will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it's a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there's an extra store/load of the value of the expression (since it has to be computed within the try block). Is there a way to force garbage collection? Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers(). Is there regular expression (regex) support available to C# developers? Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the System.Text.RegularExpressions namespace. Does C# support properties of array types? Yes. Here's a simple example: using System; class Class1 { private string[] MyField; public string[] MyProperty { get { return MyField; } set { MyField = value; } } } class MainClass { public static int Main(string[] args) { Class1 c = new Class1(); string[] arr = new string[] {"apple", "banana"}; c.MyProperty = arr; Console.WriteLine(c.MyProperty[0]); // "apple" return 0;

} } What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords) When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden. Why would you use untrusted verification? Web Services might use it, as well as non-Windows applications. How is method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class. What is the implicit name of the parameter that gets passed into the class set method? Value, and its datatype depends on whatever variable we are changing. How do I register my code for use by classic COM clients? Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class What is the Microsoft.NET? .NET is a set of technologies designed to transform the internet into a full scale distributed platform. It provides new ways of connecting systems, information and devices through a collection of web services. It also provides a language independent, consistent programming model across all tiers of an application. The goal of the .NET platform is to simplify web development by providing all of the tools and technologies that one needs to build distributed web applications. What is CLS? Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages. What is managed code? The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. The code that runs within the common language runtime is called managed code. What is the .NET Framework? The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. The .NET Framework has two main components: the common language runtime (CLR) and .NET Framework class library. The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality. What is CLR? The .NET Framework provides a runtime environment called the Common Language Runtime or CLR. The CLR can be compared to the Java Virtual Machine or JVM in Java. CLR handles the execution of code and provides useful services for the implementation of

the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in turn provide a robust and secure execution environment for .NET applications. What is CTS? Common Type System (CTS) describes the datatypes that can be used by managed code. CTS defines how these types are declared, used and managed in the runtime. It facilitates cross-language integration, type safety, and high performance code execution. The rules defined in CTS can be used to define your own classes and values. What is MSIL? When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code. MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. What is JIT? JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU. Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls. What is portable executable (PE)? PE is the file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR. How does an AppDomain get created? AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications. What is an assembly? An assembly is a collection of one or more .exe or dlls. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations. What are the contents of assembly? A static assembly can consist of four elements: Assembly manifest - Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources. Type metadata - Binary information that describes a program. Microsoft intermediate language (MSIL) code. A set of resources. What are the different types of assembly? Assemblies can also be private or shared. A private assembly is installed in the installation directory of an application and is accessible to that application only. On the other hand, a shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC. We also have satellite assemblies that are often used to deploy language-specific resources for an application. What is an application domain? Application domain is the boundary within which an application runs. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To

access the code running in another application domain, an application needs to use a proxy. What is a dynamic assembly? A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies. What is a strong name? You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly. The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation. What is GAC? What are the steps to create an assembly and add it to the GAC? The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to. Steps - Create a strong name using sn.exe tool eg: sn -k mykey.snk - in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")] - recompile project, and then install it to GAC in two ways : drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool) gacutil -i abc.dll What is the caspol.exe tool used for? The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels. What are generations and how are they used by the garbage collector? Generations are the division of objects on the managed heap used by the garbage collector. This mechanism allows the garbage collector to perform highly optimized garbage collection. The unreachable objects are placed in generation 0, the reachable objects are placed in generation 1, and the objects that survive the collection process are promoted to higher generations. What is Ilasm.exe used for? Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected. What is Ildasm.exe used for? Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code. What is a garbage collector? A garbage collector performs periodic checks on the managed heap to identify objects that are no longer required by the program and removes them from memory. What is the ResGen.exe tool used for? ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies. Which namespace provides classes for Regular Expression? System.Text.RegularExpressions namespace provides classes for Regular Expression Which file sets the environment variables for Visual Studio? The vsvars32.bat sets the environment variables for Visual Studio. You can find it from %Microsoft Visual Studio 2008\Common7\Tools\vsvars32.bat. When you start the Visual Studio 2008 command prompt it automatically runs vsvars32.bat. Which assembly is used for Mobile web application? System.Web.Mobile what namespace is used for the controls in a mobile web application?

System.Web.UI.MobileControls what is Reflection? Reflection is the feature in .Net, which enables us to get some information about object in runtime. That information contains data of the class. Also it can get the names of the methods that are inside the class and constructors of that object. program should use the reflection derived from namespace System.Reflection . using reflection can dynamically load assembly. What are the elements inside an assembly? A .NET assembly consists of the following elements, A Win32 File Header A CLR file header CIL code Type Metadata An assembly manifest Optional embedded resources What is the namespace to use LINQ to XML? System.Xml.XLinq What is the role of compiler? Compiler translates a high level language into machine language. Which namespace is used to create a multi-threaded application? System.Threading Why HashTable is used It is a .NET class that allows an element to be accessed using a unique key. It is mainly used in database programming. What is the base class for all .NET classes? System.Object What is an Assembly in .NET? When you compile an application, the MSIL code created is stored in an assembly.Assemblies include both executable application files(.exe files)& libraries(.dll extension)for use by other application. In addition to containing MSIL,assemblies also include met information(i.e. information about the information contained in assembly,also called as meta-data)and optional resources(sound and picture file, etc).The meta information enables assemblies to be fully self-descriptive.You need no other information to use an assembly,meaning you avoid situations such as failing to odd required data to the system registry and so on,which was often a problem when developing with other platforms. Microsoft .NET Interview Question Answers collected from various sources.Please leave comments and your suggestions Difference between String and Stringbuilder reference types? System.string provides a set of members for working with text.Like search,replace,concratinate etc.. and strings of type system.string are immutable(that means any change to string causes a runtime to create a new string and abandon old one). System.stringbuilder is used to dynamic strings which are mutable also.these string classes also overrides operators from System.object. What is the difference between debug build and release build? The biggest difference between these is that: In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account.

While in release build the symbolic debug info is not emitted and the code execution is optimized. Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable. One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are ususally referred to as Release - Only bugs :) In terms of execution speed, a release executable will execute faster for sure, but not always will this different be significant. Can we force garbage collector to run? System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if situation arises. What are the various ways of hosting a WCF service? There are three major ways to host a WCF service:1. Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class. 2. Host in application domain or process provided by IIS Server. 3. Host in Application domain and process provided by WAS (Windows Activation Service) Server. What are Dead letter queues? The main use of queue is that you do not need the client and the server running at one time. So its possible that a message will lie in queue for long time until the server or client picks it up. But there are scenarios where a message is of no use after a certain time. So these kinds of messages if not delivered within that time span it should not be sent to the user. Below is the config snippet which defines for how much time the message should be in queue. Microsoft .Net Interview Questions Answers What is the difference between VB 6 and VB.NET? VB 1,Object-based Language 2,Doesn't support Threading 3,Not powerful Exception handling mechanism 4,Doesn't having support for the console based applications 5,Cannot use more than one version of com objects in vb application called DLL error 6,Doesn't support for the Disconnected data source. VB.Net 1,Object-oriented Language 2,supports Threading 3,powerful Exception handling mechanism 4,having support for the console based applications 5,More than one version of dll is supported 6,supports the Disconnected data source by using Dataset class What are the authentication methods in .NET? There are 4 types of authentications. 1.WINDOWS AUTHENTICATION 2.FORMS AUTHENTICATION 3.PASSPORT AUTHENTICATION 4.NONE/CUSTOM AUTHENTICATION The authentication option for the ASP.NET application is specified by using the tag in the Web.config file, as shown below: other authentication options

1. WINDOWS AUTHENTICATION Schemes I. Integrated Windows authentication II. Basic and basic with SSL authentication III. Digest authentication IV. Client Certificate authentication 2. FORMS AUTHENTICATION You, as a Web application developer, are supposed to develop the Web page and authenticate the user by checking the provided user ID and password against some user database 3.PASSPORT AUTHENTICATION A centralized service provided by Microsoft, offers a single logon point for clients. Unauthenticated users are redirected to the Passport site 4 NONE/CUSTOM AUTHENTICATION: If we dont want ASP.NET to perform any authentication, we can set the authentication mode to none. The reason behind this decision could be: We dont want to authenticate our users, and our Web site is open for all to use. We want to provide our own custom authentication What is Serialization in .NET? The serialization is the process of converting the objects into stream of bytes. they or used for transport the objects(via remoting) and persist objects(via files and databases) Whats the use of System.Diagnostics.Process class in .NET? By using System.Diagnostics.Process class, we can provide access to the files which are presented in the local and remote system. Example: System.Diagnostics.Process(c:aired.in.txt) local file System.Diagnostics.Process(http://www.aired.in) remote file Difference Abstract class and Interface in .NET? Abstract class: This class has abstract methods (no body). This class cannot be instantiated. One needs to provide the implementation of the methods by overriding them in the derived class. No Multiple Inheritance. Interfaces: Interface class contains all abstract methods which are public by default. All of these methods must be implemented in the derived class. One can inherit from from more than one interface thus provides for Multiple Inheritance. Explain re-clarification of object based in .NET? VB6 DOES support polymorphism and interface inheritance. It also supports the Implements keyword. What is not supported in vb6 is implementation inheritance. Also, from above, vb6 DOES provides access to third-party controls like COM, DCOM That is not anything new in .NET. How to achieve Polymorphism in VB.Net? We can achieve polymorphism in .Net i.e Compile time polymorphism and Runtime polymorphism. Compile time Polymorphism achieved by method overloading. Runtime polymorphism achieved by Early Binding or Late Binding. Provide the function pointer to the object at compile time called as Early Binding. provide the function pointer to the object at runtime called as Late Binding class emp having the method display() class dept having the method display() create objects as in the main function // Early binding dim obj as new emp dim ob as new dept obj.display()-to call the display method of emp class ob.display-to call the display method of the dept class // Late binding create object in the main class as

object obj obj=new emp obj.display()-to call the display of emp class obj=new dept obj.display()-to call the display of dept class Difference between Class And Interface in .NET? Class is logical representation of object. It is collection of data and related sub procedures with definition. Interface is also a class containing methods which is not having any definitions. Class does not support multiple inheritance. But interface can support What does mean by .NET framework? The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET What is assembly in .NET? It is a single deploy able unit that contains all the information about the implementation of classes , structures and interfaces What is an application manifest? The application manifest which gives information to the operating system, such as in which way the assembly should be deployed and will check whether administrative elevation is required or not. This is processed before the .NET-managed hosting environment loads to the assembly. What is an assembly manifest? The assembly manifest is providing information to the .NET application at runtime. It provides the information like assembly's name, version, requested permissions, and other assemblies that the .NET application references. It describes the assembly to the managed hosting environment. It acts as a directory to the modules, types, and resources in the assembly. What does a method's signature consist of? Which of the following namespaces spans across multiple assemblies? How many languages a .NET DLL can contain? What is Constructor Chaining? We can chain the call of constructor from child class to base class depending on our requirement. This concept makes sure that the matching base class constructor must be called based on the parameter passed to the child class constructor. Example: namespace ConsoleApplication1 { class A { public A(){ Console.WriteLine("Constructor A."); } public A(string s){ Console.WriteLine("Constructor A with parameter = {0}",s); } public A(string s,string t){ Console.WriteLine("Constructor A with parameter = {0} & {1}", s,t); } }

class B:A { public B():base(){ Console.WriteLine("Constructor B."); } public B(string s):base(s){ Console.WriteLine("Constructor B with parameter = {0}", s); } public B(string s, string t):base(s,t){ Console.WriteLine("Constructor B with parameter = {0} & {1}", s, t); } } class Program { static void Main(string[] args) { B b1 = new B(); B b2 = new B("First Parameter ", "Second Parameter"); Console.Read(); } } } Output: Constructor A. Constructor B. Constructor A with parameter = First Parameter & Second Parameter Constructor B with parameter = First Parameter & Second Parameter What is Application Domain? It is the execution boundary within which an application runs. Application Domain is created inside a process. One process can have multiple Application Domains. Example: Consider a Remoting scenario: 2 exe's of the client and the server are communicating with each other. 2 Application Domains will be created in the process of the server. Process: In this case, it is the executable of the Operating System that will control the interaction of the client and server exe's. the 2 exes's run in their Application Domains that will be created in the execution area(in the RAM) of the OS exe. Application Domains provide the isolation of the 2 exe's(i.e. the client and the server). Is versioning applicable to private assemblies? Yes, versioning is applicable to private assemblies too There are 2 types of versions: 1)File version 2)Assembly version File version is the default version that is assigned to any .NET assembly example: click a .exe and view its properties: File version would always be there

Assembly version is applicable when we create a shared assembly(assembly installed in a GAC) Private assemblies do not have Assembly version, but they do have File Version Difference between event and delegate? event: 1) It is a data member of a type(class/structure) 2)It is declared inside a type(class/structure) 3) It is used to generate notifications which are then passed to methods though delegates. delegate: 1)It is a datatype(reference type) that holds references of methods with some signatures.also called as function pointer. 2)It may or may not be declared inside a class. 3)It is used as the return type of an event and used in passing messages from event to methods. example 2: button1.Click+=new EventHandler(this.button1_Click); (Windows Applications) Click is the event that returns an instance of the EventHandler delegate. EventHandler delegate has the reference of button1_Click event and that helps in the communication betwen the Click event and button1_Click method Difference between a Class and Component? Class is a datatype that encloses data and function members. It can be used for implementing the various OOPS features. Component is a particular class that must implement the IComponent interface .It is the base class for all components in the common language runtime that marshal by reference. Component is remotable and derives from the MarshalByRefObject class. IComponent interface belongs to System.ComponentModel namespace. So, we can say Component is subclassification of a class Difference between imperative and interrogative code. Imperative code does not return a value. It just does performs an action. example: c# void demo() { Console.WriteLine("welcme"); } vb.net sub procedures are imperative code. sub dd() end sub Interrogative code does return a value. c# ex: int add(int a) { return a*5; }

VB.NET FUNCTIONS ex function calc(byval a as integer) as integer return a*5 end function Which controls cannot be placed on an MDI Form? These controls cannot be placed on the MDI Form 1)Components : example: BackgroundWorker, ImageList, HelpProvider, Timer 2)Printing: example: PrintDocument, PrintDialog 3)Dialogs example: ColorDialog, SaveFileDialog These controls are placed in the Component Tray window. It is the window below the Form window anad can be viewed in Design mode It contains all the controls which cannot be viewed even by default when the application executes. What is the difference between casting and boxing? casting is the technique using which we convert data of one type to data of another type. It is like a main category of boxing. boxing is a sub category of casting which deals with converting a value type to a reference type. example: 1) double d=245.66; //casting: conversion between 2 value types int a=(int)d; 2) int f=200; object z=f; //casting as well as boxing: conversion of a value type to a reference type. Which dll is known as the dll for microsoft .NET runtime ? What are the differences between an interface and an abstract class. Both interface and an abstract class cannot be instantiated and are implemented by inheriting them in other classes. The differences between them are: 1)Interfaces a)All members are public by default. b)They cannot contain fields. c)No coding of the methods or the properties is allowed. d)They do not provide implementation. e)Interfaces support multiple inheritance

f)abstract keyword is not there before the interface or its members names. Abstract classes a)All members are private by default. We can put modifiers like public, protected before the abstract class members. b)They can contain fields. c) coding of the methods or the properties is allowed.(nonabstract) we can also declare abstract methods(methods with no coding) and only the declaration d)They can provide implementation. An abstract class can implement an interface e)Abstract classes support single inherritance g)abstract keyword is required before their names and also before the abstract methods or properties. Which encoding does not allow Chinese or Arabic characters? Do events have a return type? Yes, events return a delegate. example: delegate void dd(); event dd myevent; myevent is the event name and returns the delegate dd; Can classes be marked as protected or private Yes, a class can be marked as protected but we have to use the concept of nested classes for that . For a class can be marked as private we have to use the concept of nested classes for that or declare a class in a structure example: These are valid examples: class A { protected class B { } } class C { private class D { } } //Class can also be private inside a structure struct empz { private class Class3 { } } It is OK. If a class is declared below a namespace it cannot be marked as protected or private. What will be the output of this program? using System; class Class2 { Class2() { static int i; i++; Console.WriteLine(i); } static void Main() { Class2 a = new Class2(); Class2 b = new Class2(); } } Compiler error "Modifier static is not valid for this item"

static variables are declared at Class level. Which class defines the methods for implementing drawings, shapes, writing strings in a GUI based application? Graphics class defined by the System.Drawing namespace contains methods like DrawString, DrawArc, DrawImage, DrawEllipese which are used for implementing Drawings, shapes, writing strings etc. How can you bind the debug failed assembly? You can bind the debug failed assembly by using Assembly Binding Log Viewer (fuslogvw.exe ) and also you can find out the searched paths. Can we create web application with out web.config file? Yes we can create, if there is a web.config file it will take settings from directory level web.config file. if there is no web.config file in application level then it will go for machin.config file for setting. So we can create web application without web.config file In which way you can copy the COM component to the server and register? These components provides setup program to install or remove them from the system. Suppose the component doesnt provide a setup program, you can copy it to the server and register it using the MFC RegSvr32.exe utility, as shown below: RegSvr32 MyComname.dll What is the Difference between Compiler and Translator? Compiler converts the program from one computer language to another computer language that is translating from a higher level language to a lower level language. A compiler has to cope with any valid syntax in the source language, and generate semantically equivalent code in the target language. Translator which translate one language to many other language or else we can say a translator is usually translating from a high level language to another high level language, or from a low level language to a high level language. A translator usually has a fixed body of code that is required to translate the program. What is an application pool? 1. An application pool is a set of one or more websites in IIS served by the worker process 2. Each application pool has its own worker process. 3. This process isolation prevents processing from interfacing with one another. Define the list of properties, methods and events included in SmtpClient class in the Framework? Here is some partial list of the members of the SmtpClient class... 1) Properties: Host- The name or IP address of your email server. Port- The number of the port to use when sending an email message. 2) Methods: Send- It enables you to send an email message synchronously SendAsync- It enables you to send an email message asynchronously. 3) Events: Send Completed- It is raised when an asynchronous send operation completes. What is Network Load Balancing? Network Load Balancing is a clustering technology offered by Microsoft as part of all Windows Server 2000 and Windows Server 2003 family operating systems. Network Load Balancing uses a distributed algorithm to load balance network traffic across the number of hosts, helping to enhance the scalability and availability of IP-based services, such as Web, Virtual Private Networking, Streaming Media, Terminal Services, Proxy, etc. It also provides high availability by detecting host failures and automatically redistributing traffic to operational hosts.

How can you change priority and what the levels of priority are provided by .NET? Thread Priority can be changed by using Threadname.Priority = ThreadPriority.Highest . Following are different levels of Priority provided by .NET: ThreadPriority.Highest ThreadPriority.AboveNormal ThreadPriority.Normal ThreadPriority.BelowNormal ThreadPriority.Lowest What are Merge module projects? Merge module projects are used for the packaging of files or components that are shared between multiple applications. A merge module (.msm) file includes files, resources, registry entries, and setup logic. The .msm file is merged into the deployment projects for consistent installation of a component across multiple applications. Describe XCOPY deployment. Under what conditions is it useful? When can it not be used? XCOPY deployment is a simple method of deployment where the DOS command XCOPY is used to copy the application directory and any sub directories to the target machine. You can use XCOPY deployment if your application has no dependency on shared files and requires no special actions to be taken upon deployment. If suppose one application requires more complex deployment or references shared assemblies, there you should not use XCOPY. Explain how to dynamically clone a menu in .NET? Below are the steps to dynamically clone a menu in .NET: Create an alternate MainMenu object. Clone the first menu with the CloneMenu method. Create additional menu items related to the application state. Then add the new menu items to the MenuItems collection of the top-level menu item cloned. This can be done by using the Add method to specify their order within the collection by their index. Then assign the newly created MainMenu object to the form. What is the concept of Automatic Memory Management in ASP.NET? The .NET framework has introduced a concept called Garbage collector. This mechanism keeps track of the allocated memory references and releases the memory when it is not in reference. Since it is automatic, it relieves the programmers to manage unused allocated memory. This concept of managing memory is known as Automatic Memory Management. Differences between method overloading and method overriding Method Overloading and Method Overriding are both the techniques used to implement FUNCTIONAL POLYMORPHISM They enhance the methods functionality using their respective features. overloading: 1) It involves having another method with the same name in a class or its derived class. 2)can be implemented with or without inheritance. 3)It is implemented by: a)changing the number of parameters in different methods with same name. b)changing the parameter data types (if the number of parameters are same) c)changing parameter order. 4)applicable to static as well as non static methods: 5)no keywords needed before the method names in C#. 6)also called as COMPILE TIME Polymorphism. example: int add(int a, int b) { return a+b; } int add(int a) {

return a*5; } Overriding 1) It involves having another method with the same name in a base class and derived class. 2)always needs inheritance. 3)It is implemented by having two methods with same name, same signature, but different implementations (coding)in a base class and derived class 4)applicable to nonstatic, nonprivate methods only.access modifiers of the methods are not changed in the base and derived classes. 5)virtual and override keywords are needed before the method names in base and derived classes. For overriding in firther classes, override keyword will be used, 6)RUN TIME Polymorphism example: class A { public virtual void demo() { } } class B:A { public override void demo() { } static void Main() { B obj=new B(); obj.demo(); } } Which of these is a valid path declaration?

What is CLS? CLS: Common Language Specification: It is a set of the programming rules which every .NET language must follow. CLS is used so that the code written in one language is interoperable with the code written in another language. The different .NET languages code is compiled into MSIL Code. CLS defines the infrastructure for the MSIL Code. The CLR processes the MSIL code and help in its execution. This ensures the language interoperability. EXAMPLES OF CLS: 1)Common set of data types for all the languages( CTS) Int32 datatype is implemented as int in C# and as integer in VB.NET 2)Interfaces cannot have static methods.It applies to all the .NET languages. The Types which follow the CLS rules are also called as CLS Compliant types. CLS compliant languages: VB.NET,C#, VC++ Use of CLS: A class written in VB.NET can be used in C# and vice-versa.

For the complete list of CLS features, please visit this link. What is .NET Framework? .NET (.Network Enabled Technologies) is a collection of development tools developed by the Microsoft Corporation that enables the developers to develop and execute a large variety of applications example: Console,Windows,Web,WPF,WCF, Web Services, Window Services, Mobile Applications. .NET Framework consists of: 1)CLR: (Common Language Runtime): 2)FCL: (Framework Class Llivraries) 3)Languages, Language Compilers CLR is the set of components(also called as the execution engine) and provides us with many runtime services. example: 1)Managing code execution. 2)Menory management and Garbage Collection. 3)Exception handling management 4)Security and Code Verification 5)MultiThreading support 6)Cross Language interoperability using CTS and CLS. FCL provides us with the predefined class libraries which have over thousands of classes that can be used in development and execution. example: System.Data.dl System.Windows.Forms.dll System.dll mscorlib.dll Languages :example: VB.NET, C#,VC++ Each language ahs its own set of compilers ex: vbc for vb.net, csc for csharp. Coompilers are used to compile the code and generate the executable files.(Assemblies) What is difference between out and ref in c#? This is a great .NET Interview question and also very very confusing question. By default parameters are always passed by value to methods and functions.If you want to pass data byref then you can use either out or ref keyword. There are two big difference between these keywords one is the way data is passed between the caller code and method and second who is responsible for initialization. Way the data is passed(directional or bi-directional) ================================================== When you use OUT data is passed only one way i.e from the method to the caller code. When you use REF , Data can be passed from the called to the method and also vice versa. Who initializes data ============================================== In OUT the variables value has to be intialized in the method. In REF the value is initialized outside the method by the caller.

The most important thing the interviewer will like to hear from you When to use when ====================================================== OUT will be used when you want data to be passed only from the method to the caller. REF will be used when you want data to be passed from the called to the method and also vice versa. My 100 .NET Interview questions http://www.questpond.com Which of these collections uses keys to uniquely identify the data? What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ? The list of differences are huge. In interviews you normally need to short and sweet. So we will list down top 5 differences from each section. So lets first start with the difference between 1.0 and 2.0. Support for 64 bit application. Generics SQL cache dependency Master pages Membership and roles Now the next difference .NET 2.0 and 3.0 ========================================= WCF WPF WWF WCS ( card space) 3.0 and 3.5 ========================================== LINQ Ajax inbuilt ADO Entity framework ADO data services Multi targeting Finally 3.5 and 4.0 =========================================== MEF Parallel computing DLR dynamic Code contract language runtime Lazy initialization Which of these collections can be made as readonly? Differences between Window and Web Forms Window Forms: 1)They do not need a web browser or web server to execute. 2)They execute through their respective exe files 3)They run on the same machine they are displayed on. 4)Their single instance exists until we close them or dispose them through coding 5)Used for developing games, inventory management, system utiltites etc. 6)They run under Code Access Security. Web Forms:

1)They need a web browser as well as a web server(on the server machine only). 2)They execute through the dll of the web application which is then processed by IIS and the .net framework. 3)They run on a remote server and are displayed remotely on the clients. 4)Every time they are submitted, their new instance is created. 5)Used in web site development. 6)They use role based security What is XSL? XSL stands for Extensible Style Language: It is basically a formatting language using which we can convert an XML document into an HTML document. XSL is similar to CSS but specific for XML documents. XSL has its own set of namespaces and elements using which we can apply the formatting. What is PInvoke? Pinvoke (PlatForm Invoke) features of the .NET enables .NET Code to call functions from unmanaged libraries like user32.dll, kernel32.dll. Thse libraries contain Window API functions like FlashWindow, GetComputerName respectively. FlashWindow can be used to blink the form's caption bar. GetComputerName can be used to retreive the computer's name. How you load dynamic assembly? How will create assemblies at run time? You can load the assembly dynamically by using classes from the System.Reflection namespace. Assembly x = Assembly.LoadFrom( Custom.dll ); You can create assembly by using classes from System.CodeDom.Compiler

Вам также может понравиться