Mid
From PDF
MNC Coding
C# MNC Coding Interview
struct vs class (real-world)?
struct vs class (real-world)
What interviewers test
- Memory & performance awareness
Use struct when:
- Small
- Immutable
- Value-type behavior
public readonly struct Point
{
public int X { get; }
public int Y { get; }
}
Use class when:
- Large
- Mutable
- Shared references
public class User
{
public string Name { get; set; }
}
Interview statement
“Structs live on stack or inline, classes live on heap with GC cost.”
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png