Skip to content

Instantly share code, notes, and snippets.

View erasif99's full-sized avatar

Asif Ghanchi erasif99

  • Ahmedabad
View GitHub Profile
@erasif99
erasif99 / CSharpInterviewQA.md
Created January 8, 2025 09:59
C# Interview Question & Answer 2025
  1. What is boxing and unboxing in C#? Answer: Boxing is the process of converting a value type (e.g., int, float) to a reference type (e.g., object) so that it can be stored on the heap. Unboxing is the process of converting a reference type (e.g., object) back to a value type. It involves extracting the value from the boxed object.

  2. What is Managed or Unmanaged Code? Managed code in C# runs within a managed environment like the Common Language Runtime (CLR), providing automatic memory management and security features. Unmanaged code, however, operates outside of such environments, directly interacting with system resources and requiring manual memory management.

  3. What is the difference between a struct and a class in C#? Class and struct are both user-defined data types but have some major differences: Struct The struct is a value type in C# and inherits from System.Value Type. Struct is usually used for smaller amounts of data. Struct can’t be inherited from other types. A structure can't be abstract.