C#C
C#3y ago
UnionRings

❔ Determine what variable is being referenced

I come from a primarily C++ background, and I take it C# is trying it's best to hold my hand and keep me from shooting myself in the foot, but I don't entirely understand local reference variables due to their limitations. In C++, I can determine whether a pointer is referencing something by comparing it's value against another address.
if (somePtr == &someVar) { ... }

How would I accomplish the same thing with local reference variables in C#?
int someVar = 0;
ref int someRef = ref someVar;
// how can I determine someRef is still referring to someVar?
Was this page helpful?