© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
14 replies
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) { ... }
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?
int someVar = 0;
ref int someRef = ref someVar;
// how can I determine someRef is still referring to someVar?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

_sdbModel Model not being referenced
C#CC# / help
3y ago
❔ ✅ Lifetime of variable referenced in Func<>
C#CC# / help
3y ago
✅ why is the variable not being typed?
C#CC# / help
16mo ago