掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Generics.Collections.TDictionary の ContainsValue (ID:40020)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
演算子のオーバーロードはrecord型でしか出来ないぽいですね。 Dictionaryに入れて検索する目的だとEqualsメソッドてのがTObjectで宣言されてるのでそいつをオーバーライドしてやるです。 +とかの演算子をオーバーロードするならこっちの方法は駄目ですね。 TCity = class(TObject) Country : string; Latitude : Integer; Longitude : Integer; function Equals(V: TObject): boolean; override; end; function TCity.Equals(V: TObject): boolean; var V1: TCity; begin if V is TCity then begin V1 := V as TCity; if AnsiSameText(V1.Country, Country) And (V1.Latitude = Latitude) And (V1.Longitude = Longitude) then Result := True else Result := False; end else Result := False; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.