![]() |
AW: Array Properties
Zitat:
Delphi-Quellcode:
Die
uses
mormot.core.base, mormot.core.json, mormot.core.text, mormot.core.rtti, mormot.core.unicode; type TItem = class(TObject) private FIntValue: Integer; FStrValue: RawUtf8; public constructor Create(pmIntValue: Integer; const pmcStrValue: RawUtf8); published property IntValue: Integer read FIntValue; property StrValue: RawUtf8 read FStrValue; end; constructor TItem.Create(pmIntValue: Integer; const pmcStrValue: RawUtf8); begin inherited Create; FIntValue := pmIntValue; FStrValue := pmcStrValue; end; var json: RawJson; list: TObjectList; begin list := TObjectList.Create(True); try for var i: Integer := 0 to 4 do list.Add(TItem.Create(i, StringToUtf8(i.ToString))); json := ObjectToJson(list, [woHumanReadable, woObjectListWontStoreClassName]); ShowMessage(Utf8ToString(json)); list.Clear; ObjectLoadJson(list, json, TItem); ShowMessage(Format('Count: %d - Item(3): %d, %s',[list.Count, TItem(list[3]).IntValue, Utf8ToString(TItem(list[3]).StrValue)])); finally list.Free; end; ![]() Bis bald... Thomas |
AW: Array Properties
Zitat:
Also wenn es keine Mehrfachdeklaration ist, dann stimmt das. Ansonsten nicht. Ist das gleiche wie bei typisierten Zeigern.
Delphi-Quellcode:
Beides ließe sich allerdings mit einem Hardcast zu einem dritten, kompatiblen Typen umgehen.
var
a1: array of ... b1: array of ... a2, b2: array of ... begin a1 := b1; // geht nicht a2 := b2; // geht end; |
AW: Array Properties
a2 & b2: Jupp, EINE Typdeklaration für zwei Typenbezeichner ... die sind natürlich identisch.
Das
Delphi-Quellcode:
selber ist jedes Mal was Neues,
array of ...
aber
Delphi-Quellcode:
nicht.
TArray<...>
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz