Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Retrieve data value as a pointer in C#
A pointer is a variable whose value is the address of another variable. Retrieve the data stored at the located referenced by the pointer variable, using the ToString() method.
Example
Here in an example −
using System;
namespace UnsafeCodeApplication {
class Program {
public static void Main() {
unsafe {
int var = 100;
int* p = &var;
Console.WriteLine("Data is: {0} " , var);
Console.WriteLine("Data is: {0} " , p->ToString());
Console.WriteLine("Address is: {0} " , (int)p);
}
Console.ReadKey();
}
}
}
Output
Above will require you to set unsafe comman line option. After seeting it, the following output would be visible.
Data is: 100 Data is: 100 Address is: 77678547
Advertisements
