我有以下密封课.我正试图将列表作为一个返回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) 这是我第一次安装 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+ 中。我用什么来替换这个功能?