Friday 18 September 2015

C#.Net Interview Questions and Answers for freshers pdf free download

21. So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll?
Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.

22. 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.

23. 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.

24. 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.

25. Is XML case-sensitive? 
Yes, so and are different elements.
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
26. 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.

27. 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.

28. 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.

29. Will finally block get executed if the exception had not occurred? 
Yes.

30. What is the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? Does C# support try-catch-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

More Questions & Answers:-

No comments:

Post a Comment