12.5. Summary

  • Strings in C# are immutable. The String class cannot be subclassed, and, just as in Java, the CLR optimizes String objects through the process of interning. This means that strings having the same value are represented by the same String instance object.

  • C#'s String.Equals() method is similar to Java's String.equals() method; they both equate the actual value of the string. The == operator in C# is overloaded and compares the string values instead of comparing object references as in Java. To compare the object references of the strings in C#, you use the == operator on the object class.

  • Unlike Java, adding C# string literals using the + operator does not result in the use of the StringBuilder class. In fact, using the + operator ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.