Pointers in VB.NET??

  • Thread starter Thread starter IcedCrow
  • Start date Start date
I

IcedCrow

I am a little bit confused so am proposing this question.
Thanks in advance to anyone who can answer it for me.

I was told many times that one of the things that .NET got
rid of was pointers. So for the past year and a half I
have been running under this assumption.

Today I ran into something called an "IntPtr" which is a
structure that acts as... a pointer!! (This is in VB.NET,
I imagine it is everywhere then)

What's the deal then? I take it you can use pointers
in .NET?

I see a common use for IntPtr is to act as a handle (the
example given in the documentation is for file handles for
System.IO classes) but can these be used like C++ pointers?

Thanks!
~IC
 
IcedCrow said:
I am a little bit confused so am proposing this question.
Thanks in advance to anyone who can answer it for me.

I was told many times that one of the things that .NET got
rid of was pointers. So for the past year and a half I
have been running under this assumption.

Today I ran into something called an "IntPtr" which is a
structure that acts as... a pointer!! (This is in VB.NET,
I imagine it is everywhere then)

What's the deal then? I take it you can use pointers
in .NET?

I see a common use for IntPtr is to act as a handle (the
example given in the documentation is for file handles for
System.IO classes) but can these be used like C++ pointers?

Thanks!
~IC


Pointers and pointers are not the same. ;-) In VB.Net there are no pointers
in the sense of C++ pointers. But, of course, references to objects located
somewhere in memory must be stored. As they point to the object these
references could also be called "pointers", but acutally we call them
"variables declared as a type that is a reference type". An IntPtr is
usually only used with Interop, i.e. when calling unmanaged API functions.
They must be there because not everything can be done in the managed world
and because the managed world is built upon the unmanged world.
 
: but can these be used like C++ pointers?

In what way do you mean? In syntax, like &var and *var? Then no.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"


: I am a little bit confused so am proposing this question.
: Thanks in advance to anyone who can answer it for me.
:
: I was told many times that one of the things that .NET got
: rid of was pointers. So for the past year and a half I
: have been running under this assumption.
:
: Today I ran into something called an "IntPtr" which is a
: structure that acts as... a pointer!! (This is in VB.NET,
: I imagine it is everywhere then)
:
: What's the deal then? I take it you can use pointers
: in .NET?
:
: I see a common use for IntPtr is to act as a handle (the
: example given in the documentation is for file handles for
: System.IO classes) but can these be used like C++ pointers?
:
: Thanks!
: ~IC
 
Back
Top