小编Deb*_*bie的帖子

为什么我收到错误:"无法隐式转换类型System.Collections.Generic.List"

我有以下密封课.我正试图将列表作为一个返回ReadOnlyCollection.尝试了几件事,但我没有掌握这一点.那么如何将列表返回或转换为只读集合?

    public sealed class UserValues
    {
        private readonly List<UserValue> _Values = new List<UserValue>();

        public ReadOnlyCollection<UserValues> Values
        {
            get
            {
                return _Values;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# readonly-collection

6
推荐指数
1
解决办法
5290
查看次数

如何将 LockBox 3 安装到 Delphi 7 中?

这是我第一次安装 Lockbox 的库。我从sourceforge下载了3.4.3版本,并拥有Delphi 7。第一步是让这个傻瓜在Delphi 7下编译,这真是太糟糕了。我确实希望这些组件在安装后更容易使用。

好的。我有一个看起来像这样的单位。

unit uTPLb_StrUtils;

interface

uses
  SysUtils, uTPLb_D7Compatibility;

function AnsiBytesOf(const S: string): TBytes;

implementation

function AnsiBytesOf(const S: string): TBytes;
begin
//compiler chokes here
  **Result := TEncoding.ANSI.GetBytes(S);**
end;

end.
Run Code Online (Sandbox Code Playgroud)

顺便说一句,兼容性单元将 TBytes 定义为 TBytes = 字节打包数组;

Delphi 7 对 TEncoding 感到窒息,因为它只存在于 D2009+ 中。我用什么来替换这个功能?

delphi lockbox-3

3
推荐指数
1
解决办法
1495
查看次数

标签 统计

c# ×1

delphi ×1

lockbox-3 ×1

readonly-collection ×1