boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

Top C# Interview Questions for Experienced

Updated on     Kisan Patel

Frequently asked C# interview questions and answers for Experienced.

1. What is the difference between strong typing and weak typing in .NET?

Strong typing means that the type check is done at compile time and weak typing means that the type check is done at run time. .NET languages incorporate strong typing.

Reference: C# dynamic Data Type

2. Difference between Hashtable and Dictionary in C#

In C#, Dictionary is a generic collection which is generally used to store key/value pairs. Dictionary is defined under System.Collection.Generics namespace. It is dynamic in nature means the size of the dictionary is growing according to the need.

A Hashtable is a collection of key/value pairs that are arranged based on the hash code of the key. Or in other words, a Hashtable is used to create a collection which uses a hash table for storage. It is the non-generic type of collection which is defined in System.Collections namespace. In Hashtable, key objects must be immutable as long as they are used as keys in the Hashtable.

Reference: Link

3. Difference between string and StringBuilder in C#

String is immutable in C# that would mean you couldn’t modify it after it is created. It creates a new object of string type in memory if you will perform any operation.

StringBuilder is mutable in C#. This means that if an operation is performed on the string, it will not create a new instance every time. With that, it will not create new space in memory, unlike Strings.

Reference: Link

4. Explain Value Type and Reference Type in C#

A data type is a value type if it holds a data value within its own memory space. It means the variables of these data types directly contain values.

Unlike value types, a reference type doesn’t store its value directly. Instead, it stores the address where the value is being stored. In other words, a reference type contains a pointer to another memory location that holds the data.

Reference: Link

5. Difference Between Const, ReadOnly and Static ReadOnly in C#

Const is nothing but “constant”, a variable of which the value is constant but at compile time. And it’s mandatory to assign a value to it. By default a const is static and we cannot change the value of a const variable throughout the entire program.

Readonly is the keyword whose value we can change during runtime or we can assign it at run time but only through the non-static constructor. Not even a method.

A Static Readonly type variable’s value can be assigned at runtime or assigned at compile time and changed at runtime. But this variable’s value can only be changed in the static constructor. And cannot be changed further. It can change only once at runtime.

Reference: Link

6. Difference Between Namespace and Assembly

A namespace is a logical group of related classes that can be used by the languages targeting the Microsoft .NET framework. Storing all the classes in the same location will create difficulties in accessing and maintenance. Therefore, it is possible to use namespace as an alternative. In other words, a namespace helps to group the classes logically. Also, it groups the names and reduces the chance of name collisions.

Assembly is a standard component of the Microsoft .NET framework. It can exist as an executable (.exe) file or Dynamic Link Library (DLL) file. An assembly consists of all metadata about the modules, types and other elements in the form of a manifest. Moreover, the assembly provides multiple advantages. Generally, it helps deployment and version control and provides reusability and security.

Reference: Link

7. Static keyword in C#

In C# OOPS, all the members (E.g. variables, methods) of the class are instance members of that class. That means they belong to object being created.

But, Static members belong to the class rather than to individual object.

Reference: Link, Static vs. Non-Static method in C#

8. Explain ref & out Keywords in C#?

The ref and our keyword can be used to change the behavior of the method parameters. When we pass a variable to the method, the runtime generated a copy and passes that copy to the method.

In the case of the ref keyword, the variable must be initialized before passing it to the method by reference.

C# out and ref, both keyword indicate that the parameter is being passed by reference. However, when using the out keyword, is not necessary to initialize the variable.

Reference: Link

9. The is and as Operators in C#

The is operator is used to check if the run-time type of an object is compatible with the given type or not whereas as operator is used to perform conversion between compatible reference types or Nullable types.
The is operator is of boolean type whereas as operator is not of boolean type.
The is operator returns true if the given object is of the same type whereas as operator returns the object when they are compatible with the given type.
The is operator returns false if the given object is not of the same type whereas as operator return null if the conversion is not possible.

Reference: Link

10. Explain break and continue Statements in C#?

A Break statement breaks out of the loop at the current point or we can say that it terminates the loop condition.

The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

Reference: Link

11. What is a copy constructor in C#?

Copy Constructor creates an object by copying variables from another object.

Reference: Link

12. Explain Collections in C#?

Collection classes are specialized classes for data storage and retrieval. These classes provide support for stacks, queues, lists, and hash tables. Most collection classes implement the same interfaces.

The following are the various commonly used classes of the System.Collection namespace:

ArrayList
Hashtable
SortedList
Stack
Queue
BitArray

Reference: Link

13. What is static method and instance method in C#?

The static method is defined with a static keyword. The static method uses class memory rather than an object. Static Method is called by class name. We can call a non-static function in static function by making an object of the class. We can’t use this keyword inside the static function.

Non-static method or instance method is defined without static keyword. The non-static method is called by making an object of the class. We can use this keyword inside the non-static method. The non-static method uses a memory of the object.

Reference: Link

14.What is Explicit Interface Implementation and when is it used?

If a class implements from more than one interface that has methods with the same signature then the call to such a method will implement the same method and not the interface specific methods. This will defeat the whole purpose of using different Interfaces. That is when Explicit implementation comes into the picture. Using explicit implementation you can tell the compiler which interface’s method you are Overloading and can provide different functionalities for methods of different interfaces.

Reference: Link

15. Explain Multiple inheritance using interfaces C#?

Multiple Inheritance isn’t supported in C#. To implement multiple inheritances, use Interfaces.

Reference: Link

16. Type vs Type Members in C#

Reference: Link

17. Private Constructors in C#

Private Constructor is a special instance constructor present in C# language. Basically, private constructors are used in class that contains only static members. The private constructor is always declared by using a private keyword.

Using private constructor, prevents the creation of the instances of that class.

If we don’t use any access modifier to define a constructor, then the compiler takes that constructor as a private.

Reference: Link

18. What is the difference between IEnumerable and IQueryable in C#?

  • IEnumerable
    IEnumerable exists in the System.Collections namespace.
    IEnumerable is suitable for querying data from in-memory collections like List, Array and so on.
    While querying data from the database, IEnumerable executes “select query” on the server-side, loads data in-memory on the client-side and then filters the data.
    IEnumerable is beneficial for LINQ to Object and LINQ to XML queries.
  • IQueryable
    IQueryable exists in the System.Linq Namespace.
    IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
    While querying data from a database, IQueryable executes a “select query” on server-side with all filters.
    IQueryable is beneficial for LINQ to SQL queries.

19. Explain Indexers in C#?

Reference: Link

20. What are sealed classes and sealed methods in C#?

Sealed classes are classes that cannot be inherited. You can use the sealed keyword to define a class as sealed class.

The method that is defined in a parent class, if that method cannot be overridden under a child class, we call it a sealed method. By default, every method is a sealed method because overriding is not possible unless the method is not declared as virtual in the parent class. If a method is declared as virtual in a class, any child class of it can have the rights to override that method. the sealed keyword is always used with override keyword so that further overriding of the method will not be possible.

Reference: Link

21. What is Partial Class in C#?

A partial class is a special feature of C#. It provides a special ability to implement the functionality of a single class into multiple files and all these files are combined into a single class file when the application is compiled. A partial class is created by using a partial keyword.

22. Explain Attributes in C#?

An attribute is a declarative tag that is used to convey information to runtime about the behaviors of various elements like classes, methods, structures, enumerators, assemblies etc. in your program. You can add declarative information to a program by using an attribute. A declarative tag is depicted by square ([ ]) brackets placed above the element it is used for.

Reference: Link

23. Explain Singleton design pattern with locks in C# with example?

Singleton design pattern in C# is one of the most common design patterns is software design. In singleton design pattern ensures a class has only one instance in the program and provides a global point of access to it. A singleton is a class that only allows a single instance of itself to be created and usually gives simple access to that instance.

public sealed class Singleton  
{  
    private Singleton()  
    {  
    }  
    private static readonly object padlock = new object();  
    private static Singleton instance = null;  
    public static Singleton Instance  
    {  
        get  
        {  
            lock (padlock)  
            {  
                if (instance == null)  
                {  
                    instance = new Singleton();  
                }  
                return instance;  
            }  
        }  
    }  
}

Reference: Link

What is the difference between IEnumerator and IEnumerable?

IEnumerable is an interface that defines one method GetEnumerator which returns an IEnumerator interface, this in turn allows readonly access to a collection. A collection that implements IEnumerable can be used with a foreach statement.

IEnumerable

public IEnumerator GetEnumerator();

IEnumerator

public object Current;
public void Reset();
public bool MoveNext();

Reference: Link


C#

Leave a Reply