[1.0/1.1] Reference operator: Checking the memory location (maybe a noob question)
Hello,
In C++, if we declare an object of type, say int, we can check its memory location using reference operator, i.e. &.
Is some kind of Reference operator also present in C#?? Or is it possible to check the memory location in C# also?? If yes, how??
Thank you.
Re: [1.0/1.1] Reference operator: Checking the memory location (maybe a noob question)
Quote:
Originally Posted by Harsh Gupta
Hello,
In C++, if we declare an object of type, say int, we can check its memory location using reference operator, i.e. &.
Is some kind of Reference operator also present in C#?? Or is it possible to check the memory location in C# also?? If yes, how??
Thank you.
I will give you a link because I think the following page gives better and more complete information than I could possibly give you:
Pointer Types (C# Programming Guide) @ MSDN
Well it's not recommonded of course. Usually I put [CLSCompliant(true)] at the start of most of my classes. That makes my C# classes reusable in all the other .NET languages (such as VB.NET, J#.NET, ... etc.) Personally I see it like a quality-Indicator for myself. There are some conditions to be able to put this CLSCompliant tag though. Just one of them is <not using pointers>.
I hope I have enlightened you :).
Re: [1.0/1.1] Reference operator: Checking the memory location (maybe a noob question)
Thanks for the link. I was just curious to know about Pointers in C#, otherwise I agree with your point that using unsafe keyword is not a good practise.
Re: [1.0/1.1] Reference operator: Checking the memory location (maybe a noob question)
Bah!
It's only not a good practice if you don't know what you're doing. Which, since you've used C/C++, I assume you do.
Re: [1.0/1.1] Reference operator: Checking the memory location (maybe a noob question)
Quote:
Originally Posted by penagate
It's only not a good practice if you don't know what you're doing.
You should be careful however when creating a Code Library Project (DLL) that you will reuse in other .NET languages.
"A small tactical decision can have huge strategic consequences."