Common C# Interview Questions
Last Update: Dec 31, 2022
I wrote a book! Check out A Quick Guide to Coding with AI.
Become a super programmer!
Learn how to use Generative AI coding tools as a force multiplier for your career.
I was reading a post about some common C# interview questions, and thought I’d share some of mine. These are questions that I asked in interviews, or was asked in past interviews. Try them out and see you how you do! I’m not going to post the answers here, if you don’t know them, find out!
Common C# (and .Net) Interview Questions
- What are the different types of collections in .Net?
- What are the benefits offered by generics as opposed to other collections?
- What is the difference between a class and a struct?
- When calling a function, are parameters passed by value or by reference?
- What are the different ways to pass a parameter by reference?
- What are the mechanisms for maintaining state in an asp.net application?
- Describe inheritance. Describe different ways you can implement inheritance.
- What is dependency injection?
- How do you override a static method?
- Name some of the parts of the page life cycle in ASP.NET.
- Where I would validate something like an email address?
- What is the difference between public, static and void?
- What are Jagged Arrays?
- What is serialization?
- Can “this” be used within a static method?
- What is the difference between Array and Arraylist?
- Can a private virtual method be overridden?
- Describe the accessibility modifier “protected internal”.
- What are the differences between System.String and System.Text.StringBuilder?
- What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
- What’s the difference between an interface and abstract class?
- What is the difference between Finalize() and Dispose() methods?
- What’s an object pool?
- What is the difference between method overriding and method overloading?
- What is the difference between a Struct and a Class?
- What are Indexers?
MS SQL
- What are the different ways for storing behaviors in SQL?
- What are the different kinds of SQL joins? When would you use each?
- If you have a slow running query that looks at seldom changed data, how might you speed it up?
- Describe the different types of joins?
- What is the no-lock feature?
- How do you make sure you maintain your referential integrity?
- He asked me to describe the Controller?
- What is a clustering index?
- How do you handle an error in a SQL query?
{% include custom/asides/dotnet-newsletter-banner.html %}
Exercises
- Name the 3 language features that make a programming language object-oriented.
- Write a C# method that takes an array of integers and returns the largest integer in the array
- Explain the difference between pass by value and pass by reference?
- Write a C# method that will reverse a string (e.g. “abcd” -> “dcba”). Make sure that it works.
- Write a function that tests if a string is a Palindrome
- Write this same function recursively
- Write a function that acts as a telegraph, that has a set limit of characters per line (for example only 20 characters per line) and break it up so you don’t split any words.
Summary
These are just a few I had stored over the years for interviews, but I’ll come up with some more. It’s always good to keep brushed up on this stuff to make sure your skill level is where you think it should be.