Autor Beitrag
hydemarie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 475
Erhaltene Danke: 51



BeitragVerfasst: Di 16.06.20 19:44 
Sehr kurzer Ausriss aus meinem aktuellen Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
unit MainUnit;

// ...

type
  // ...
  TTranslateDictionary = TObjectDictionary<stringString>;

var
  transTable: TTranslateDictionary;

implementation

procedure FillTransTable;
begin
  transTable := TTranslateDictionary.Create([doOwnsValues]);
  // ...
end;


FillTransTable aufzurufen wirft mir aber jedes Mal einen Fehler: "Ungültige Typumwandlung". Das passiert eindeutig in dem, was oben Zeile 16 ist. Spannende Frage an dieser Stelle: Warum?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.06.20 20:15 
user profile iconhydemarie hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
type
  // ...
  TTranslateDictionary = TObjectDictionary<stringString>;
Fällt dir etwas auf?

// EDIT:
Das siehst du im Debugger allerdings eigentlich auch gleich...

TypeCheckError
Einloggen, um Attachments anzusehen!

Für diesen Beitrag haben gedankt: hydemarie
hydemarie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 475
Erhaltene Danke: 51



BeitragVerfasst: Di 16.06.20 20:22 
Ist mit zweimal "String" und zweimal "string" immer noch dasselbe. (Aber ja, das hatte ich nicht bedacht. Zu viel Go in letzter Zeit...)
edit: oder gehen Zeichenketten gar nicht?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.06.20 21:52 
user profile iconhydemarie hat folgendes geschrieben Zum zitierten Posting springen:
edit: oder gehen Zeichenketten gar nicht?
Strings sind keine Objekte! Deshalb funktioniert das mit OwnsObjects natürlich nicht.

Ein normales TDictionary<stringstring> geht...

Moderiert von user profile iconTh69: Delphi-Tags hinzugefügt

Für diesen Beitrag haben gedankt: hydemarie
hydemarie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 475
Erhaltene Danke: 51



BeitragVerfasst: Di 16.06.20 22:06 
Ah. Hier hatte ich das mit Strings gesehen ...

Du hast Recht, danke. :D