c# 如何获取一个变量内存地址
并对他进行操作
并对他进行操作
解决方案 »
- 文本提取的问题---正则表达式
- C# winform treeview 求高手指点 急!!!!!!!!
- RadioButton控件对checked属性的封装问题?
- sql 如何替换某个字段里的空格
- DataGridView不显示数据
- 打造最好的.NET2.0开发团队
- 请帮忙告诉一下,在select ISNULL(SUM(c.Amount), 0) from.......中 ISNULL(SUM(c.Amount), 0)的含义??
- 如何获取SQL数据库中某个表属性中的最后更新时间
- 请问一下combox的问题
- 怎么用.Net的Framework得到文件大小?
- opengl网格化问题
- DataTable序列化,反序列化问题
ReadProcessMemory
WriteProcessMemory
比如我操作指定内存的0x56000000
位置的值该怎么做的?!
{
uint* ptr = (uint*)0x56000000;
MessageBox.Show((*ptr).ToString());
}
1.将IDE中的配置属性->结构->unsafe设置为true;
2.在要取内存地址的函数前用unsafe关键词修饰。
3.用&取内存地址
{
class Program
{
static void Main(string[] args)
{
//函数实现数值交换
int a, b;
Console.Write("请输入要交换的两个数");
a= Convert .ToInt32 ( Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("输入需要要交换的两个数{0},{1}", a, b);
Swap(ref a, ref b); // !!!注意:获取的是地址!!!!
Console.WriteLine("交换后的a,b值{0},{1}",a,b);
Console.ReadKey();
} private static void Swap(ref int a,ref int b)//传过来的是地址
{
int c ;
c = a;
a = b;
b = c; }
private static int Average(int[] array)
{
int agevage=0;
int sum=0;
for (int i = 0; i < array.Length; i++)
{ sum+= array[i];
agevage = sum / array.Length;
}
return agevage ;
} static int Min( params int[] array)
{
int min = array [0];
for (int i = 0; i < array .Length ; i++)
{ if (min >array [i])
{
min = array [i]; } }
return min; }
private static int Compare(int[] arr)
{
int max=0;
for (int i=0;i<arr.Length ;i++)
{
if (max < arr[i])
{
max = arr[i];
}
}
return max;
}
private static bool YesNo()
{
Console.WriteLine("请问是否继续计算? 是Y/否N");
string yesno = Console.ReadLine();
if (yesno == "Y" || yesno == "y")
{
return true ;
}
else
return false ;
}
}
}