Pergunta de entrevista da empresa ServiceTitan

What is the most accurate way to check for equality by reference?

Resposta da entrevista

Sigiloso

22 de jun. de 2024

If you're talking about C#, `System.Object.ReferenceEquals()` is the most reliable way. Contrary to popular belief `==` doesn't always work as expected. It works for most reference types, but not for `string`. Read up on "string interning" and "value references" to understand why.