use*_*179 3 c# pointers unsafe
我正在尝试初始化SecureString,我需要Char*.我尝试使用不安全的代码块:
unsafe {
char[] c = { 'A', 'B', 'C', 'D' };
char* pointer = &(c[0]);
SecureString sec = new SecureString(pointer, 4);
}
Run Code Online (Sandbox Code Playgroud)
试试这个时我得到了这个错误:
错误:您只能在固定语句初始化程序中获取未固定表达式的地址
为什么不循环遍历每个char并使用AppendChar?
string s = "Hello";
SecureString ss = new SecureString();
foreach(char c in s) ss.AppendChar(c);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2195 次 |
| 最近记录: |