Most reliable split character

后端 未结 11 2137
忘掉有多难
忘掉有多难 2021-01-31 01:49

Update

If you were forced to use a single char on a split method, which char would be the most reliable?

Definition of reliable: a split charact

11条回答
  •  爱一瞬间的悲伤
    2021-01-31 02:43

    First of all, in C# (or .NET), you can use more than one split characters in one split operation.

    String.Split Method (Char[]) Reference here
    An array of Unicode characters that delimit the substrings in this instance, an empty array that contains no delimiters, or null reference (Nothing in Visual Basic).

    In my opinion, there's no MOST reliable split character, however some are more suitable than others.

    Popular split characters like tab, comma, pipe are good for viewing the un-splitted string/line.

    If it's only for storing/processing, the safer characters are probably those that are seldom used or those not easily entered from the keyboard.

    It also depend on the usage context. E.g. If you are expecting the data to contain email addresses, "@" is a no no.

    Say we were to pick one from the ASCII set. There are quite a number to choose from. E.g. " ` ", " ^ " and some of the non-printable characters. Do beware of some characters though, not all are suitable. E.g. 0x00 might have adverse effect on some system.

提交回复
热议问题