What is the difference between mutable and immutable in C# and VB.NET

What is the difference between a mutable and immutable string in C# and VB.NET?

  • A mutable string can be changed.
  • An immutable string cannot be changed.
  • Mutable is the english word for can change. Immutable is the english word for cannot change.

    if you alter a String, you are creating a new string object internally. So String is immutable. If you alter a StringBuilder no new Objects are created internally so, StringBuilder is mutable.

    Please rate this snippet

    How to check if a variable exists in Python

    To check if a variable exists in Python, you can use the snippet below.

    Sample Python

    if 'myVariable' in locals(): # myVariable exists locally.
    if 'myVariable' in globals(): # myVariable exists globally.
    

    Please rate this snippet