请教一个C#编程问题
请教:
//
#define VIRTUAL_SYSTEM_ASIC_REGS_BASE (0x90000000 | 0x20000000)
#define WATCHDOG_BASE (VIRTUAL_SYSTEM_ASIC_REGS_BASE + 0x00940000)
#define WATCHDOG_WDCONTROL ((volatile ULONG *)(WATCHDOG_BASE + 0x00))
#define WATCHDOG_WDSTATUS ((volatile ULONG *)(WATCHDOG_BASE + 0x04))
#define WDCONTROL_DISABLE 0xAA55
#define WDCONTROL_ENABLE 0xAAAA
// 激活watchdog
*WATCHDOG_WDCONTROL = WDCONTROL_ENABLE;
// 关闭watchdog
*WATCHDOG_WDCONTROL = WDCONTROL_DISABLE;
上述代码功能在C#中如何实现?是用指针吗?会不会受到限制?
谢谢。。
------解决方案--------------------不清楚,帮顶了啊
------解决方案--------------------不清楚,帮顶了啊
------解决方案--------------------不清楚,帮顶!
------解决方案--------------------不懂,帮顶
------解决方案--------------------C#中没有指针
define中定义的可以通过常量来实现
------解决方案--------------------public static Class SomeConstParameters
{
public static unsigned long VIRTUAL_SYSTEM_ASIC_REGS_BASE = (0x90000000 ¦ 0x20000000);
public static unsigned long WATCHDOG_BASE = ((0x90000000 ¦ 0x20000000) + 0x00940000)
public static unsigned long WATCHDOG_WDCONTROL = WATCHDOG_BASE;
public static unsigned long WATCHDOG_WDSTATUS = WATCHDOG_BASE + 0x04;
public static unsigned long WDCONTROL_DISABLE = 0xAA55 ;
public static unsigned long WDCONTROL_ENABLE = 0xAAAA ;
}
------解决方案--------------------C#中有指针,但要包含在unsafe里,被称为不安全代码,在你声明的不安全代码区可以使用指针,但没有宏定义,可以用readonly的形式来达到同样效果。