I am trying to add following values to
procedure TForm1.FormCreate(Sender: TObject);
var
md: TDictionary<string, string>;
s, v: string;
begin
md := TDictionary<string, string>.Create;
try
s := 'orange';
v := 'fruit';
md.Add(s, v);
s := 'orange ';
v := 'color';
md.Add(s, v);
ShowMessage(IntToStr(md.Count));
finally
md.Free;
end;
end;
I know this is duplicate but if you look at second orange, you can see a space at the end. I think Delphi trims the value but it shouldn't.
Does anyone know solution of this problem?
Thanks,
This code shows a message box containing the number 2 on all known versions of Delphi. That is exactly as is expected and the TDictionary
code most certainly does not trim your keys when comparing for equality.