

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are pointers in C#?
Pointer is a variable whose value is the address of another variable i.e., the direct address of the memory location.
The syntax of a pointer is −
type *var-name;
The following is how you can declare a pointer type −
double *z; /* pointer to a double */
C# allows using pointer variables in a function of code block when it is marked by the unsafe modifier. The unsafe code or the unmanaged code is a code block that uses a pointer variable.
The following is our module showing how to declare and use a pointer variable. We have used unsafe modifier here −
static unsafe void Main(string[] args) { int val = 50; int* x = &val; Console.WriteLine("Data: {0} ", val); Console.WriteLine("Address: {0}", (int)x); Console.ReadKey(); }
- Related Questions & Answers
- What are Wild Pointers in C/C++?
- What are pointers to structures in C language?
- What are the different types of pointers in C language?
- Pointers, smart pointers and shared pointers in C++
- What are different pointer operations and problems with pointers in C language?
- Why are NULL pointers defined differently in C and C++?
- Pointers in C/C++
- Function pointers in Java
- Pointers vs References in C++
- Applications of Pointers in C/C++
- RAII and smart pointers in C++
- What is the difference between Java references and pointers in other languages?
- near, far and huge pointers in C
- How to compare pointers in C/C++?
- Difference between Array and Pointers in C.
Advertisements