1。写个函数function StrComp(S1,S2:string):string;
如果s1包含s2就返回s1,否则返回s1+s2,有什么好的方法吗?
2。delphi用属性的作用?我是菜鸟我敢问,马上结贴!在线

解决方案 »

  1.   

    function StrComp(S1,S2:string):string;
    begin
    if AnsiContainsStr(S1,S2) then
        result:=S1
    else
        result:=S1+S2
    end;
      

  2.   

    delphi用属性的作用?
    类、封装
      

  3.   

    function StrComp(S1,S2:string):string;
    begin
      if strpos(pchar(S1),pchar(S2))<>nil then
        result:=S1;
      else
        result:=S1+S2;
    end;
    属性的作用,比如可以判别输入的合法性,它是代码的一种访问机制。也是一种良好的封装。
      

  4.   

    else 前多打了个分号不好意思