C# DotNet Interview Preparation - Part 11
Question 61: What is the difference between string and StringBuilder in C#?
Answer:
: Immutable (creates a new object on modification).
: Mutable (modifies the same object, better for performance when modifying strings frequently).
Code Example:
Question 62: What is the difference between readonly and const in C#?
Answer:
Feature Value Assignment Assigned in constructor or declaration Must be assigned at declaration Modification Can be changed in constructor Cannot be changed after declaration Runtime or Compile-time? Runtime constant Compile-time constant
Code Example:
Question 63: What is the difference between Dispose() and Finalize() in C#?
Answer:
: Explicitly called to release unmanaged resources ().
: Called by the Garbage Collector before the object is destroyed.
Code Example:
Question 64: What is the difference between throw and throw ex in C#?
Answer:
: Preserves the original exception stack trace.
: Resets the stack trace (not recommended).
Code Example:
Question 65: What is yield return in C#?
Answer: " allows returning elements one by one without creating a collection in memory."
Code Example:
Question 66: What is the difference between Array and Listlt;Tgt; in C#?
Answer:
Feature Size Fixed Dynamic Performance Faster (fixed size) Slightly slower (resizable) Methods Limited Rich API (, , etc.)
Code Example:
Hashtags for LinkedIn/YouTube Video:
#DotNetBasics
#CSharpLearning
#CodeWithCSharp
#AspNetCoreBeginner
#DotNetForBeginners
#TechEducation
#InterviewReady
#CodingBestPractices
#SoftwareDevelopmentTips
#LearnToCode
.NET Developer @ Hesabrasyar
5moI believe discussing ArrayPool and ObjectPool could be a great topic to explore, especially in technical interviews. Both are powerful tools for optimizing memory and resource management in .NET. ArrayPool helps reduce the overhead of frequent array allocations by reusing arrays, while ObjectPool allows for the reuse of objects, minimizing garbage collection pressure. These concepts are particularly valuable in high-performance applications where efficiency is critical.