C# is a popular programming language developed by Microsoft. It is based on OOP (Object-Oriented Programming) principles. C# uses the .NET framework to build various applications, including websites, video games, Windows applications, IoT applications, and reusable libraries. This is why big companies seek skilled C# developers to add to their teams.
Here are some commonly asked C# interview questions and answers to help you start with your C# interview preparations.
The main characteristics of C# are:
An object in C# is an instance of a class that contains data and behavior as defined in the class. It is a runtime entity.
There are three different data types in C# based on the type of data they hold - value type, reference type, and pointer.
The value datatypes store the data directly in the form of stacks. Examples of value datatypes are int, float, and char. Etc. The reference datatypes hold a reference to the variables rather than the actual data. They are stored in a heap. Reference datatypes include classes, arrays, delegates, and interfaces. The pointer datatype is used to store the address of another datatype.
A jagged array is also called an array of arrays. This means a jagged array is an array whose elements are arrays. The elements of a jagged array can have any dimensions and sizes, unlike a multidimensional array.
The different types of classes in C#
Static class: these classes cannot be instantiated. This means you cannot create an object of a static class. A static class is created using the keyword ‘static’.
Abstract class: Abstract classes also cannot be instantiated and are only meant to be subclassed. The keyword ‘abstract’ is used to declare an abstract class.
Sealed class: this is the type of class that cannot be inherited.
Partial class: allows a class to be divided into multiple files.
Arrays are strongly typed which means their type of element cannot be changed once declared and it stores only that datatype. On the other hand, ArrayLists are not strongly typed which means they can store elements of any datatypes.
Arrays are of fixed size once they are created. ArrayLIsts have a dynamic size and their size changes as elements are added to or removed from it.
Once the source code is created, the compilation involves
C# interview questions and answers are the perfect refresher you need to confidently face a technical C# interview. Whether you are a C# fresher or an experienced professional, brushing up on your basics and working out more technical questions will increase your chances of acing your next C# job interview.