【问题标题】:Help converting from WinForm to Windows-Mobile帮助从 WinForm 转换到 Windows-Mobile
【发布时间】:2011-06-14 08:40:37
【问题描述】:

我的 Winform C# 程序中有这段代码:

sb.Append(Encoding.Default.GetString(new byte[] { b }));

而且效果很好非常好

当我在我的 C# Windows-mobile 程序上尝试它时,我收到了这个错误:

No overload for method 'GetString' takes '1' arguments

有什么问题?

【问题讨论】:

    标签: c# winforms windows-mobile


    【解决方案1】:

    完整的 .NET 框架非常大,对于小型设备来说太大了。因此,当他们创建 Compact Framework 时,他们不得不削减一些 API。结果是对 CF 1.0 进行了相当残酷的调整,并且这些年来他们慢慢地添加了一些东西。

    有时,您会遇到缺少特定覆盖的 API。答案as Eden said 是使用受支持的不同覆盖。在这种情况下:

    Encoding.GetString (Byte[] toDecode, Int32 indexOfFirstByteToDecode, 
      Int32 numberOfBytes)
    

    【讨论】:

      【解决方案2】:

      查看 MS 文档: http://msdn.microsoft.com/en-us/library/system.text.encoding.getstring(v=VS.80).aspx

      .NET Compact Framework (Windows mobile) 中未提供您使用的方法。您将需要使用需要另外 2 个参数的第二个版本:索引和计数。

      【讨论】:

      • @Gali,哇哇哇,你能搞定的!您只需要开始的索引和数组中的内容数量。您的代码中已经包含您需要的所有信息! :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      • 2011-05-13
      • 1970-01-01
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多