
Preparing for a C# interview requires more than rote learning the answers. You must have a deep understanding of the language and know how to use it practically. So, take the time to go over 100 C# technical interview questions before going to your next interview. Interviewers are impressed by candidates who come prepared and can speak about C# fundamentals and show a real-world application of concepts. By going through the following questions, you will be able to strengthen your knowledge and answer questions the right way. Whether you wish to apply for an entry-level role or a senior position, being well-prepared can set you apart from other candidates. Use this interview questions guide to brush up on your skills and ace your C# interview.
- Generics are a technique that enhances the programs in the following ways:
- It helps to maximize code reuse, type safety, and performance.
- Allows creation of generic collection classes. The .NET Framework class library contains numerous new generic collection classes in the System.Collections.Generic namespace. You should use these generic collection classes in place of the collection classes in the System.Collections namespace.
- You can make your own generic classes, methods, interfaces, events, and delegates.
- You may create generic classes constrained to allow access to methods on specific data types.
- You may get information on the types useful in a generic data type at run-time using reflection.
- ArgumentException
- ArithmeticException
- DivideByZeroException
- OverflowException
- InvalidCastException
- InvalidOperationException
- NullReferenceException
- OutOfMemoryException
- StackOverflowException
- String objects are immutable that holds a string value whereas StringBuilder is a mutable object.
- Performance-wise, a string is slower as it creates a new instance to override or change the previous value as compared to StringBuilder which faster because it uses the same instance of the StringBuilder object to perform any operation, like inserting a value in the existing string.
- String belongs to the System namespace while StringBuilder belongs to System.Text namespace.
- IEnumerable interface comprises the System.Collections.Generic namespace.
- IEnumerable interface is a generic interface which permits looping over generic or non-generic lists.
- IEnumerable interface works with linq query expression.
- IEnumerable interface Returns an enumerator that iterates through the collection.