Answer to C# Programming Problem (by Robert C. Cartaino)
-
False
True
In the second comparison, the output is True because c and d refer to string literals. In C#, hard-coded strings with the same value (c = 10, d=10), don't necessarily result in a new string instance being created. A C# compiler in .NET uses something called an intern pool which contains a single reference to each unique literal string declaration in your system. So every time you reference the same string literal, you get a reference to the same string. So the comparison of two objects containing the same literal string results in True.
- Link to C Strings Tutorial
- Link to C++ Strings Tutorial
- Link to C# Strings Tutorial


Comments
No comments yet. Leave a Comment