在C#中,将数据值作为指针检索
指针是一个变量,其值是另一个变量的地址。使用ToString()方法检索指针变量所引用的位置存储的数据。
示例
以下是一个示例 -
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(); } } }登录后复制