tags:

views:

275

answers:

4
+2  Q: 

Pointers in C# ?

In one C# maintenance project I came across following variable declaration:

Int32* iProgressAddress;

Is it pointer declaration in C#?

I thought that there is no pointer concept in C#, what does that statement mean?

+4  A: 

C# does support pointers, but it's limited to pointing to primitive data types that are unmanaged types, such as ints, floats, enums, and other pointer types (plus the rest of the primitives).

edit: as well as value types

Sev
Not quite correct. You can have pointers to all *value types*, including structs, not just primitives. But only structs that don't contain reference type variables.
JulianR
+3  A: 

Yes, it is.

Notice, that the method is marked unsafe. As well as the assembly.

There is a lot of things to know before using pointers from the managed code. For instance, pointer pinning.

modosansreves
+1  A: 

I'm sorry, I'm afraid that's a pointer, and you have to get used to it.

REALLY! Pointers aren't that scary. :)

Suvesh Pratapa