-
What is Programming?
-
Programming is the process of taking an Algorithm and Encoding it into a Notation, a Programming language, so that it can be executed by a computer. In simple, Program is a Precise Sequence of steps to solve a particular Problems.
-
What is C#?
-
C# is a type-safe, managed and object oriented language, which is compiled by .Net framework for generating intermediate language (IL). C# provides the rapid application development found in Visual Basic with the power of C++. Its syntax is similar to C++ syntax and meets 100% of the requirements of OOPs like, Abstraction, Encapsulation, Polymorphism and Inheritance. (Read more...)
-
What is Object?
-
a class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically".
-
What is Managed Code?
-
The code, which is developed in .NET framework is known as managed code. This code is directly executed by CLR with the help of managed code execution. Any language that is written in .NET Framework is managed code.
-
What is Unmanaged Code?
-
he code, which is developed outside .NET framework is known as unmanaged code. Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with the code of VB, ASP and COM are examples of unmanaged code.
-
What is Boxing?
-
Boxing is the process of converting a value type data type to the object or to any interface data type which is implemented by this value type. When the CLR boxes a value means when CLR is converting a value type to Object Type, it wraps the value inside a System.Object and stores it on the heap area in application domain.
//Example:
public void Method()
{
int i = 0;
object obj = i; //Implicit Boxing:
console.WriteLine(obj);
}
-
What is Unboxing?
-
Unboxing is also a process which is used to extract the value type from the object or any implemented interface type. Boxing may be done implicitly, but unboxing have to be explicit by code.
//Example:
public void method()
{
object obj = 0;
int i = (int)obj; //explicit Unboxing:
console.WriteLine(i);
}
-
What is Enum?
-
An enum is a value type with a set of related named constants often referred to as an enumerator list. The enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined. (Read More...)
-
Why we Use "Continue" and "Break" Statement?
-
When we want to Jump Over one Iteration and then resume our Loop execution, we use Continue statement. and When we want to jump out of the Loop execution, we use Break Statement.
-
What is the Difference between Ref & Out Keyword?
-
Ref | Out |
The Parameter of argument must be initialized first before it is passed to ref. | It is not Compulsory to Initialize a parameter of argument before it is passed to an out. |
It is not required to assign or initialize the value of a parameter(which is passed by ref) Before returning to the Calling method. | A called Method is required to assign or Initialize a value of a parameter (which is passed to an out) before returning to the calling method. |
Passing a Parameter value by ref is useful when the called method is also needed to modify the pass parameter. | Declaring a Parameter to an Out Method is useful when multiple values need to be returned from a function or Method. |
It is Not compulsory to Initialize a Parameter value before using it in a calling method. | A Parameter value must be initialized within the Calling Method before it use. |
When we use Ref, Data can be Passed bi-directionally. | When we Use Out Data is passed only in a Unidirectionally way. |
-
What is Extension Method?
-
Extension methods enable you to add methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. An extension method is a special kind of static method, but they are called as if they were instance methods on the extended type.
-
What is Delegates?
-
delegates are same as pointers to functions, in C or C++. A delegate Object is a reference type variable that use to holds the reference to a method.
-
What is Sealed Class?
-
Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited.
-
What is Singleton Design Pattern?
-
A singleton is a class that only allows a single instance of itself to be created, and usually gives simple access to that instance.
-
What is Indexer?
-
Indexer are smart Arrays, used for treating an Object as an Array.
-
What is The difference between Equality Operator (==) and Equals() Method?
-
Both the == Operator and the Equals() method are used to compare two value type data items or reference type data items. The Equality Operator (==) is the comparison operator and the Equals() method compares the contents of a string. The == Operator compares the reference identity while the Equals() method compares only contents.
-
What is the difference between "Is" and "as" Operator?
-
In the C# language, we use the "is" operator to check the object type. If the two objects are of the same type, it returns true and false if not.
The "as" operator behaves similar to the "is" operator. The only difference is it returns the object if both are compatible to that type else it returns null.
-
Define Serialization?
-
Serialization means saving the state of your object to secondary memory, such as a file.
-
What is Jagged Array?
-
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays."
-
What is Multithreading?
-
The real usage of a thread is not about a single sequential thread, but rather using multiple threads in a single program. Multiple threads running at the same time and performing various tasks is referred as Multithreading. A thread is considered to be a lightweight process because it runs within the context of a program and takes advantage of resources allocated for that program.
-
What is Anonymous type?
-
Anonymous types allow us to create new type without defining them. This is way to defining read only properties into a single object without having to define type explicitly.
-
What is Hashtable?
-
A Hashtable is a collection that stores (Keys, Values) pairs. Here, the Keys are used to find the storage location and is immutable and cannot have duplicate entries in the Hashtable.
-
What is LINQ?
-
LINQ stands for Language Integrated Query. LINQ is a data querying methodology which provides querying capabilities to .NET languages with a syntax similar to a SQL query. LINQ has a great power of querying on any source of data. The data source could be collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable interface.
-
What is Reflection?
-
Reflection typically is the process of runtime type discovery to inspect metadata, CIL code, late binding and self-generating code. At run time by using reflection, we can access the same "type" information as displayed by the ildasm utility at design time.
-
What is the Difference between "Dispose" and "Finalize" Variables?
-
Dispose - This method uses interface – “IDisposable” interface and it will free up both managed and unmanaged codes like – database connection, files etc.
Finalize - This method is called internally unlike Dispose method which is called explicitly. It is called by garbage collector and can’t be called from the code.
-
Explain "Static" Keyword?
-
“Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance.
-
Explain Namespace in C#?
-
Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#. “Using” keyword can be used for using the namespace in other namespace.
-
Why we use "Finally" Block in C#?
-
“Finally” block will be executed irrespective of exception. So while executing the code in try block when exception is occurred, control is returned to catch block and at last “finally” block will be executed. So closing connection to database / releasing the file handlers can be kept in “finally” block.
-
Can we use “this” inside a static method in C#?
-
No. We can’t use “this” in static method.
-
Can we Overrid Private Virtual Method in C#?
-
No. We can’t override private virtual methods as it is not accessible outside the class.
-
What is Difference between "StringBuilder" and "String" in C#?
-
StringBuilder is mutable, which means once object for stringbuilder is created, it later be modified either using Append, Remove or Replace.
String is immutable and it means we cannot modify the string object and will always create new object in memory of string type.
-
What are the differences between events and delegates in C#?
-
Main difference between event and delegate is event will provide one more of encapsulation over delegates. So, when you are using events destination will listen to it but delegates are naked, which works in subscriber/destination model.
-
What is Nullable Types in C#?
-
Variable types does not hold null values so to hold the null values we have to use nullable types. So nullable types can have values either null or other values as well.
-
What we Need Lock Statement?
-
Lock will make sure one thread will not intercept the other thread which is running the part of code. So lock statement will make the thread wait, block till the object is being released.
-
What is Thread in c#?
-
Thread is an execution path of a program. Thread is used to define the different or unique flow of control. If our application involves some time-consuming processes then it’s better to use Multithreading., which involves multiple threads.
-
What is Method Overloading?
-
When methods are created with the same name, but with different signature its called overloading.
-
What is Data Encapsulation?
-
Data Encapsulation is defined as the process of hiding the important fields from the end user.
-
Can multiple catch blocks be executed?
-
No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed
-
What are Custom Control and User Control?
-
Custom Controls are controls generated as compiled code (Dlls), those are easier to use and can be added to toolbox. Developers can drag and drop controls to their web forms. Attributes can be set at design time. We can easily add custom controls to Multiple Applications (If Shared Dlls), If they are private then we can copy to dll to bin directory of web application and then add reference and can use them.
User Controls are very much similar to ASP include files, and are easy to create. User controls can’t be placed in the toolbox and dragged – dropped from it. They have their design and code behind. The file extension for user controls is ascx.
-
What is the difference between Array and Arraylist?
-
In an array, we can have items of the same type only. The size of the array is fixed. An arraylist is similar to an array but it doesn’t have a fixed size.
-
What is an object pool in .NET?
-
An object pool is a container having objects ready to be used. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and re-creating objects.
-
Discuss what garbage collection is and how it works. Provide a code example of how you can enforce garbage collection in .NET.
-
Garbage collection is a low-priority process that serves as an automatic memory manager which manages the allocation and release of memory for the applications. Each time a new object is created, the common language runtime allocates memory for that object from the managed Heap. As long as free memory space is available in the managed Heap, the runtime continues to allocate space for new objects. However, memory is not infinite, and once an application fills the Heap memory space, garbage collection comes into play to free some memory. When the garbage collector performs a collection, it checks for objects in the managed Heap that are no longer being used by the application and performs the necessary operations to reclaim the memory. Garbage collection will stop all running threads, it will find all objects in the Heap that are not being accessed by the main program and delete them. It will then reorganize all the objects left in the Heap to make space and adjust all the Pointers to these objects in both the Stack and the Heap.
-
Explain the difference between the Stack and the Heap.
-
The short answer would be: in the Stack are stored value types (types inherited from System.ValueType), and in the Heap are stored reference types (types inherited from System.Object).
We can say the Stack is responsible for keeping track of what is actually executing and where each executing thread is (each thread has its own Stack). The Heap, on the other hand, is responsible for keeping track of the data, or more precise objects.