相关疑难解决方法(0)

为什么.NET String是不可变的?

众所周知,String是不可变的.String不可变的原因是什么,StringBuilder类的引入是可变的?

.net c# string immutability

182
推荐指数
8
解决办法
10万
查看次数

为什么TPageProducer没有从字符串中删除引号?

我正在尝试调试仅在我的大型应用程序 - 在XE3中正常工作 - 在使用XE4编译后运行时才出现的行为.该问题似乎导致一些引用的字符串(例如"MyString")即使在由Web.HTTPProd中的TPageProducer"解除引用"之后仍保留其引号.例如,考虑以下代码,该代码是来自此Delphi源单元Web.HTTPApp的小提取:

procedure ExtractHeaderFields(Separators, _WhiteSpace: TSysCharSet; Content: PChar;
  Strings: TStrings; Decode: Boolean; StripQuotes: Boolean = False);
{$ENDIF NEXTGEN}
var
  Head, Tail: PChar;
  EOS, InQuote, LeadQuote: Boolean;
  QuoteChar: Char;
  ExtractedField: string;
{$IFNDEF NEXTGEN}
  WhiteSpaceWithCRLF: TSysCharSet;
  SeparatorsWithCRLF: TSysCharSet;
{$ENDIF !NEXTGEN}

  function DoStripQuotes(const S: string): string;
  var
    I: Integer;
    InStripQuote: Boolean;
    StripQuoteChar: Char;
  begin
    Result := S;
    InStripQuote := False;
    StripQuoteChar := #0;
    if StripQuotes then
    begin
      for I := Result.Length - 1 downto 0 do
        if Result.Chars[I].IsInArray(['''', '"']) then …
Run Code Online (Sandbox Code Playgroud)

delphi string delphi-xe4

8
推荐指数
1
解决办法
353
查看次数

标签 统计

string ×2

.net ×1

c# ×1

delphi ×1

delphi-xe4 ×1

immutability ×1