Tuesday 28 February 2017

C# basic interview questions Part-5

1. Ques : What are the advantages of generics?
Answer:
Generics has following advantages
  • It allows creating class, methods which are type-safe
  • It is faster. Because it reduce boxing/un-boxing
  • It increase the code performance
  • It helps to maximize code reuse, and type safety

2. Ques : What is extension methods and where can we use it?
Answer:
Extension methods provide a feature to add new capabilities to an existing type. You don’t need to make any modifications to the existing type, just bring the extension method into scope and you can call it like a regular instance method.
Extension methods need to be declared in a non generic, non-nested, static class.


3. Ques : What is difference between the “throw” and “throw ex” in .NET?
Answer:
  • throw : It throws the original exception and preserves its original stack trace.
  • throw ex: It throws the original exception but resets the stack trace, destroying all stack trace information until your catch block.

4. Ques : Can you serialize hashtable ?
Answer
No, You can’t Serialize Hash table.Because, In the C# serialization of any object not possible  that implements the IDictionary interface.


5. Ques : What is the difference between Debug.Write and Trace.Write in C#?
Answer
Debug.Write
  • It uses the Debug class.
  • It uses the time of application development.
  • It works only in debug mode.
  • It is used while debugging a project.
  • It runs in the same thread as main program executes.
  • It is used to find errors in the program.
  • If 'DEBUG' is defined during the compilation, Debug.Write will be emitted.
Trace.Write
  • It uses the Trace class.
  • It uses the time of application deployment.
  • It works in both case debug and release mode.
  • It is used in releasing version of applications.
  • It runs in different thread form main program execute thread.
  • It is used for testing and optimization even after an application is compiled and released.
  • If 'TRACE' is defined during the compilation, Trace.Write will be emitted.

6. Ques: What is the difference between an EXE and a DLL?
Answer:
EXE:
  •  Executable file can run independently.
  •  It runs in a separate process.
  •  It can’t be reused in application.
  •  it has a main function.
  • Can be started as stand alone.
DLL:
  • Dynamic link library is used as part of EXE or other DLL’s
  • It runs in application process memory.
  • It can be reused in application.
  • It does not have a main function.
  • Cannot be started as stand alone.

7. Ques:  What is strong name in .net ?
Answer:
A strong name consists of the assembly's identity  its simple text name, version number, and culture information,  a public key and a digital signature.


8. Ques: What is delay signing Dot Net ?
Answer:
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.


9 Ques: What is side by side execution in .net ?
Answer:
Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time.


10 Ques: Can we have different access modifiers on get/set methods of a property ?
Answer:
No we can not have different modifiers same property. The access modifier on a property applies to both its get and set accessors.

No comments:

Post a Comment

Thank you for comment