There are several restrictions to using pointers in C#. I've included a link to the MSDN section on using pointers in C# below.
I would encourage the use of objects instead of pointers if you can get away with it. Pointers are considered "unsafe" types, and must be included in trusted assemblies (if compiled into an assembly) to be accessed.
I believe pointers in C# (or .NET for that matter) are allocated on the heap, unless you call stackalloc to explicitly allocate them on the stack. They are declared with an * after the type declaration for multi-pointer declarations, or an * before the variable name for single pointer declarations. Two asterisks indicate a pointer to a pointer.
Also, any methods where a pointer is declared/used must be declared with an "unsafe" declaration before the method declaration.
You can obtain further information at the URL below.
How can I use pointers in C# programming?
The design of C# is to avoid the use of pointers. "Managed Code" is what it's called. For the most part you shouldn't need pointers in C# but you still have the ability to use pointers in C# but its strongly discouraged.
Reply:Hi
Pointer is a powerful tool in 'C', it is used to know the memory address of a variable/identifier/value
Pointers are also helpful in transfer more than one values/variables/identifiers from main program/function to another function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment