class foo
{
string bar()
{
const string c = "dead beef";
return c;
}
void Test()
{
string a = bar();
string b = bar();
}
}
are a and b different instance or are they pointing to the same memory address? (the == comparison would return true regardless they are the same instance or not so I can't really test it)
Object.ReferenceEqualsto find out though.constvariables have on the generated IL, take a look at a question I asked back in '09 - stackoverflow.com/questions/1707959/…