Monday, 4 February 2019

IQ

1) Why we use Generics ?

Benefits

The following are the benefits of generics:

  • There is no need for casting for accessing the elements of the data.
  • Code is not duplicated for multiple types of data.
  • Generics can hold the data with the same type and we can decide what type of data that the collection holds.
  • You can create your own generic interface, classes, method, events and delegate.
Why to use Generics

There are mainly two reasons to use generics as in the following:

  1. Performance: Collections that store the objects uses boxing and unboxing on data types. A collection can reduce the performance.
    By using generics it helps to improve the performance and type safety.
  2. Type Safety: there is no strong type information at compile time as to what it is stored in the collection.

When to use Generics

  • When you use various #ff0000 data types, you need to create a generic type.
  • It is easier to write code once and reuse it for multiple types.
  •  If you are working on a value type then for that boxing and unboxing operation will occur, Generics will eliminate the boxing and unboxing operations.


2) why is used static constructor ?
3) Can we create instance for static constructor and why?
4) Can we pass parameters to static constructor and why?
5) What is managed and unmanaged code where its executed?
6) Give me examples for managed and unmanaged code?
7) How the memory allocation and deallocation will be happed for manged and unmanaged code?
8) What is anonymous function and why its used?
9) what is lambda expression?
10) Difference between lambda and LINQ?
11) C# Method to return a boolean from a lambda expression?
12) How Dispose method works in c#?
13) How garbage collector deallocate the memory?
14) Bundling and minification how its works in mvc?
15)String reverse program
16) Default access modifier for static constructor?

No comments:

Post a Comment