unsafe private void seekbyte()
{
bs[0]=100;
fixed ( byte* p =&bs[0])//再使用bs过程中必须固定bs否则会被回收器移动
{
IntPtr ptr=new IntPtr (p);
}
}
解决方案 »
- 菜鸟 求教
- 请教devexpress的winform界面开发基本步骤
- c#datagridview如何删除鼠标所选的数据所在的行
- vs2005中使用AJAX控件问题
- C#gridview里面的模板编辑,求高手帮忙!!!!
- 请问一个关于C# 语法的基本问题
- 在 System.ArgumentException 中第一次偶然出现的“System.Drawing.dll”类型的异常
- HELP,请推荐一个高性能文本编辑器带折叠功能
- 如何用C#实现PE文件文本的十六进制显示
- 为什么用c#做出来的程序在别的机器上无法运行?
- c# 中语句的写法,这个意思?
- 怎么没办法动态输出<!--#include file=""-->在aspx文件内?
{
bs[0]=100; bs[1]=200;
fixed ( byte* p =&bs[0])//再使用bs过程中必须固定bs否则会被回收器移动
{
IntPtr ptr=new IntPtr (p);
this.textBox1 .Text =p[1].ToString ();
}
}
大概是
System.IntPtr ptr;
byte [] b1=new byte[400];
unsafe
{
//这儿可以进行指针操作
}具体怎么做在网上搜一下吧,关键字unsafe
FileInfo fi=new FileInfo("aa");
FileStream fs=fi.OpenRead();
int nBytesRead;
System.IntPtr ptr;
byte [] b1=new byte[400];
nBytesRead=fs.Read(ah,0,400);
fs.Close();
而 Bitmap(int a1, int a2, int a2, PixelFormat a3, IntPtr ptr);
中的ptr就是对应文件读出的b1内容:
如何使ptr是b1的指针地址或b1如何用指针ptr来表示?
改为:
Bitmap(int a1, int a2, int a3, PixelFormat a4, IntPtr ptr);
改为:
nBytesRead=fs.Read(b1,0,400);
IntPtr ptr=new IntPtr (p);
应该可以的
unsafe {
System.IntPtr ptr;
byte [] b1=new byte[400];
fixed (void * ii = b1) {
ptr = new IntPtr(ii);
}
}
unsafe
{
fixed (byte* p =&file_content[0])
{
dd=new IntPtr (p);
}
}
应为:
FileInfo fi=new FileInfo("aa");
FileStream fs=fi.OpenRead();
int nBytesRead;
System.IntPtr ptr;
byte [] b1=new byte[400];
nBytesRead=fs.Read(b1,0,400);
fs.Close();
IntPtr dd;
unsafe
{
fixed (byte* p =&b1[0])
{
dd=new IntPtr (p);
}
}
成功!
谢谢各位!