PowerTip: Create Empty String with PowerShell


Summary: Learn how to create an empty string by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to create an empty string?

Hey, Scripting Guy! Answer Use the static Empty field from the System.String class:

[string]::Empty

Comments (5)

  1. Are there situations where you’d want to use [string]::Empty over $string = ""? Or do they accomplish the exact same thing?

  2. Maekee says:

    What about $string = ""

  3. Ed Wilson says:

    @Maekee sure, that works as well. With PowerShell, there is always more than one way to do the same thing.

  4. wagepal says:

    Thankful concerning such an unprecedented article here. I was chasing down something like this for really truly a while lastly I’ve ran across it on your site. It was unquestionably captivating for me to I read about web applications and their business
    segment condition nowadays. tremendously liked one all the more a chance and keep posting such charming ones in the closest future too.
    http://buysoundcloudnow.com/plays/">how to buy soundcloud plays

Skip to main content