Re: C# Fundamentals Part 3: ReferenceEquals question
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 1 Apr 2006 11:51:14 +0100
Willy Denoyette [MVP] <willy.denoyette@xxxxxxxxxx> wrote:
| It prints "true" - meaning that x and y are references to the same
| object, despite them being the results of "new" expressions.
Both x and y are initialzed to an empty string (== String.Empty), which by
itself is an interned string. The result is that x and y are references to
the same string object.
Yes - but this is the only time it ever happens. You can't create a
reference to any other interned string using "new" - and it actually
violates the spec, which says:
<quote>
The new operator implies creation of an instance of a type
</quote>
In this case, no new instance is being created :(
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: C# Fundamentals Part 3: ReferenceEquals question
- From: Willy Denoyette [MVP]
- Re: C# Fundamentals Part 3: ReferenceEquals question
- References:
- Re: C# Fundamentals Part 3: ReferenceEquals question
- From: Jon Skeet [C# MVP]
- Re: C# Fundamentals Part 3: ReferenceEquals question
- From: Willy Denoyette [MVP]
- Re: C# Fundamentals Part 3: ReferenceEquals question
- Prev by Date: Re: implicit cast operator funny-ness
- Next by Date: win32security
- Previous by thread: Re: C# Fundamentals Part 3: ReferenceEquals question
- Next by thread: Re: C# Fundamentals Part 3: ReferenceEquals question
- Index(es):
Relevant Pages
|
Loading