原来的很多写法这次,可以修改了。

原写法:

function TAopApi.GetTopTypeByAop(const aop_type: string): string;
var
  MyList: TStringList;
  I: Integer;
begin
  MyList := TStringList.Create;
  try
    MyList.CommaText := MyAopTypeToTopListStr;
    for I := 0 to MyList.Count-1 do
    begin
      if aop_type = MyList.Names[I] then
      begin
        Exit(MyList.ValueFromIndex[I]);
      end;
    end;
  finally
    MyList.Free;
  end;
end;

 

修改后:

function TAopApi.GetTopTypeByAop(const aop_type: string): string;
var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
    MyList.CommaText := MyAopTypeToTopListStr;
    Exit(MyList.Values[aop_type]);
  finally
    MyList.Free;
  end;
end;

简洁 高效 明了

只适应根据键名 找 键值的情况

posted on 2014-05-03 19:37  del88  阅读(387)  评论(0编辑  收藏  举报