Powershell Best Practice #13: Avoid double quotes in strings if not necessary

By | June 28, 2015

Best Practice: It is recommended to use single quotes if there are no variables or escape sequences in strings, otherwise, you should use double quotes.

Single quotes

Double quotes

Explanation: Single quotes disable the expansion of variables and should be preferred if there is no variable or escape sequence inside strings to reduce unexpected results (ex: if the string contains dollar sign $, etc.).


Leave a Reply

Your email address will not be published.