Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#不安全上下文中初始化sbyte**_C#_.net_Pointers_Unsafe - Fatal编程技术网

在C#不安全上下文中初始化sbyte**

在C#不安全上下文中初始化sbyte**,c#,.net,pointers,unsafe,C#,.net,Pointers,Unsafe,如何在C#不安全上下文中初始化sbyte** 我需要 sbyte** parameters; 要用三个字符串填充:“第一”、“第二”、“第三”。这里有一个可能的解决方案,使用字节**。这应该与sbyte**兼容,因为所使用的编码是ASCII,并且只有到127的值 unsafe static void Main(string[] args) { fixed (byte* arg0 = Encoding.ASCII.GetBytes(args[0]), arg1

如何在C#不安全上下文中初始化sbyte**

我需要

sbyte** parameters;

要用三个字符串填充:“第一”、“第二”、“第三”。

这里有一个可能的解决方案,使用
字节**
。这应该与
sbyte**
兼容,因为所使用的编码是ASCII,并且只有到127的值

unsafe static void Main(string[] args)
{
  fixed (byte* arg0 = Encoding.ASCII.GetBytes(args[0]), 
               arg1 = Encoding.ASCII.GetBytes(args[1]), 
               arg2 = Encoding.ASCII.GetBytes(args[2]))
  {
    byte*[] arr = { arg0, arg1, arg2 };

    fixed (byte** argv = arr)
    {
      ...
    }
  }
}

怎么样
sbyte*[]参数={“第一”、“第二”、“第三”}sbyte**
数组,例如,通过
void foo(params sbyte**arrOfSByte)的函数原型
?@Kerrek SB:无法将类型为“string”的表达式转换为类型为“sbyte*”@Freedompaese:我想调用一个以sbyte**argv作为参数的方法。啊,明白了,你需要
编码.ASCII.GetBytes()
,但这会得到
字节
,而不是
sbyte
。可以吗?