Top 10 C# Interview questions

  1. [C#] What is C#?
    A modern, object-oriented programming language developed by Microsoft. It is widely used for developing a variety of applications on the .NET framework.
  2. [C#] What are the key features of C#?
    • type safety
    • garbage collection
    • strong typing
    • component-oriented programming
    • automatic memory management
    • multi-threading support
  3. [C#] Explain the difference between value types and reference types in C#.
    • Value types store their values directly
    • Reference types store references to their values.

    Value types are typically stored on the stack.

    Reference types are stored on the heap.
  4. [C#] What is the difference between "const" and "readonly" in C#?
    The "const" keyword is used to declare a compile-time constant that cannot be changed.

    The "readonly" keyword is used to declare a value that can only be assigned at runtime or in a constructor and remains constant throughout the lifetime of the object.
  5. [C#] What is the difference between "ref" and "out" parameters in C#?
    The "ref" keyword is used to pass a variable by reference, allowing the called method to modify its value. Also must be initialized prior to use.

    The "out" keyword is similar to "ref," but it is used when the called method intends to assign a value to the parameter.
  6. [C#] What is the purpose of the "using" statement in C#?
    Used to automatically release resources such as file handles or database connections when they are no longer needed. It ensures that the objects are properly disposed of even if an exception occurs.
  7. [C#] Explain the concept of inheritance in C#.
    A fundamental feature of object-oriented programming. It allows a class to inherit the properties and behavior of another class. The derived class (subclass) can extend or override the functionality of the base class (superclass).
  8. [C#] What are delegates in C#?
    Type-safe function pointers. They are used to define and pass methods as parameters, enabling callback mechanisms and event handling. Delegates allow for loose coupling and are a key component of C# events.
  9. [C#] What is the purpose of the "finally" block in a try-catch-finally statement?
    Used to specify code that will always be executed, regardless of whether an exception is thrown or caught. It is typically used to release resources or perform cleanup operations.
  10. [C#] Explain the "async" and "await" keywords in C#.
    The "async" and "await" keywords are used to write asynchronous code in a more readable and maintainable manner.

    "async" is used to define an asynchronous method.

    "await" is used to await the completion of an asynchronous task, allowing the code to continue executing without blocking.
Author
geschw66
ID
362031
Card Set
Top 10 C# Interview questions
Description
Per ChatGPT these are the top 10 C# Interview questions
Updated