Inside C # string interpolation - $

1. interpolation string
  $ text identifies special character string is not a string interpolation, the interpolation expression may contain string text.
  Parse the string to the string interpolation result string, inserted in the expression with the result of the expression is replaced item representation.
  Use a higher priority in C # 6 language versions
  interpolation provided in the string syntax more readable and easier

2. The structure of the interpolation string
  before the string $ sign, and with no spaces between $ "
  structure: {<interpolationExpression> [, < alignment>] [: <formatString>]}
Parameters:
  interpolationExpression: generating the need to set an expression result format
  alignment: constant expression, interpolation result of its expression that defines the value represents a minimum number of characters in a string form of the value, if positive, the string representation is right-aligned; if the value. is negative, for the left-justified
  formatString: format string types supported by the results of expression
3. the special character
  to the interpolation generated text strings included in braces "{" or "}", use two braces , i.e., "{{" or "}}"
  colon ( ":") in the interpolation string has a special meaning, or using conditional expressions, conditional expressions in parentheses
  verbatim interpolated character string $ at the beginning, followed by the character @
4 and designated IFormatProvider implicit conversion achieved
  interpolation string into a string instance
  interpolation string into a compound represented by the format string FormattableStri ng example, expression result format will also
  be converted to a string interpolation instance IFormattable

Guess you like

Origin www.cnblogs.com/qidakang/p/11305308.html