Say I write a switch statement where the return value is a string. Are the strings that this switch statements return interned (since they may be referenced many times)?
Say we have an enumeration called DogBreed
.
private static string DogBreedToString(DogBreed dogBreed)
{
return dogBreed switch
{
DogBreed.GoldenRetriever => "golden_retriever",
_ => throw new InvalidOperationException($"Breed ({dogBreed}) is unsupported"),
};
}
In other words, if this gets called two times from two different parts of the code, will both parts of the code receive a reference to the same instance of "golden_retriever"
?