C# Enumerable over a type 提供不同的选项(在函数中查找更多选项)

C# Enumerable over a type gives different options (Finding more options in a function)

我在下面的代码片段中缺少导入什么转换或库?我希望能够将字节转换为数组。

示例:

  1. A.interface=> 在一个位置给出四个值 vertices.=>values 只有四个选项可供选择
  2. A.interface=> 在另一个位置给出了 30 个值。 而在另一个 class 中,我有多个选项可供选择。

    public static byte[] GetRGB32Pixels(SampleImage image, out int cwidth, out int cheight) { Sample.imagedatacdata; byte[] cpixels = null; cwidth = cheight = 0; 如果 (image.AcquireAccess(Sample.Imageaccess.ACCESS_READ, Sample.PixelFormat.PIXEL_FORMAT_RGB32, 输出 cdata) >= Sample.Status.STATUS_NO_ERROR) { cwidth = (int)cdata.pitches[0] / sizeof(Int32); cheight = (int)image.Info.height; cpixels = cdata.ToByteArray(0, (int)cdata.pitches[0] * cheight); image.ReleaseAccess(c数据); } return 像素; }

你能帮我理解一下吗?在上面的代码中,我指的是 SampleImage 数据类型。如果我在代码中扩展 SampleImage 实例 "image",我只会得到有限的选项,但在另一个 class 中,当我调用相同的 SampleImage 实例时,我会看到多个选项。

您在文件中有一个 using System.Linq,其中包含额外的选项。这种使用引入了几种有助于 LINQ 的扩展方法(请参阅有关扩展方法的详细信息 here