J
Joy Maitland
is pointer really use often in C#?
I am from a Java background and not getting used to pointers.
I am from a Java background and not getting used to pointers.
is pointer really use often in C#?
No, they are used rarely and are actively discouraged. They step outside the
bounds of managed code and as such can only be used in blocks marked with
the "unsafe" keyword. If you NEED to use them (and there are valid
situations) then you can, but most of the time there are managed equivalents
to do what you might want to do.
Kenneth said:Pointers in C# are only used for unmanaged code. They are not tracked
by the garbage collector. I can't say they're rarely used but they're
definetly not as common as in other languages.
Tom said:Maybe a nitpick - but pointers in C#, are not stepping out of bounds of
managed code... The code is still IL and is managed code.
Well the code is managed, but the pointers themself are stepping out of
the bounds, i.e. they are pointing something that is not managed.
Tom said:Not neccesarily. You can have pointer to managed memory.