Pergunta de entrevista da empresa Fidelity Investments

What is the difference between a struct and a class?

Respostas da entrevista

Sigiloso

25 de out. de 2024

class: reference type, shared mutable state, inheritance struct: value type, immutable, no inheritance

Sigiloso

3 de nov. de 2024

Structs are value type and use stack data structure, thread safe due to the creating new copy every time (value type) Classes are reference type and use heap data structure, thread safety is not guaranteed and needs manual efforts to ensure it.