The output is:
Why? When comparing two
objects, the equality operator (==) checks to see if the objects are exactly the same object (i.e. the same
reference) and not two different instances of objects. In the first comparison, to compiler creates two different objects of type int. So, even though the value in each object is the same, the object a and the object b are different objects. So the comparison of these two different instances is False.
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.
I've mentioned jobs in the past but recently came across an excellent
UK job tracking website that gets data from agencies and employers and shows salaries/contract rates for development jobs in the UK for the last three months and year on year change. As I've said before, determining the popularity of programming language is a difficult task. This website publishes the popularity (from adverts) of over 4,000 terms like Developer and Analyst as well as the languages themselves. Currently .NET ranks at 5 with C# at 8, Java at 10, C++ at 19 and C at 36.
Putting in a search term like C# actually returns 17 entries such as C#, C # Developer etc and you can narrow searches down to geographic areas or even towns and cities. For instance there were a lot more C, C++ and C# jobs in Wales than in N. Ireland. The site is an ASP.NET site and a pretty good demo of the grid component with sortable columns etc. Now if you know of similar sites say for the US or other parts of the world please email me and tell me!