
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are pointer data types in C#?
A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory location. Similar to any variable or constant, you must declare a pointer before you can use it to store any variable address.
The syntax of a pointer is −
type *var-name;
The following is how you can declare a pointer type −
int *ip; /* pointer to an integer */ double *dp; /* 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.
Here is the module showing how to declare and use a pointer variable. We have used unsafe modifier here −
static unsafe void Main(string[] args) { int var = 20; int* p = &var; Console.WriteLine("Data is: {0} ", var); Console.WriteLine("Address is: {0}", (int)p); Console.ReadKey(); }
- Related Articles
- What are enumerated data types in C++?
- What are nullable data types in C#?
- What are dynamic data types in C#?
- What are object data types in C#?
- What are reference data types in C#?
- What are the data types, value types and reference types in C#?
- What are fundamental data types in C++ programming?
- What are user defined data types in C#?
- What are primary data types in C language?
- What are string and String data types in C#?
- What are different types of data in C language?
- What are the different data types of arrays in C#?
- What are primitive data types in Java?
- What are reference data types in Java?
- What are primitive data types in JavaScript?

Advertisements