1
vote
Vote UpVote

.NET/C# duh moment of the day: “A char can be implicitly converted to ushort, int, uint, long, ulong, float, double, or decimal (not the other way around; implicit != implicit)”

The Wiert Corner – A while ago I had a “duh” moment while calling a method that had many overloads, and one of the overloads was using int, not the char I’d expect. The result was that a default value for that char was used, and my parameter was interpreted as a (very small) buffer size. I only found out something went wrong when writing unit tests around my code. The culprit is this C# char feature (other implicit type conversions nicely summarized by Muhammad Javed): A char can be implicitly converted to ushort, int, uint, long, ulong, float, double, or decimal. However, there are no implicit ...
Favorite? Off-Topic? jpluimers @ 2012-11-20 06:00

Statistics

Visits: 490
Votes: 1
Favorites: 0
Off-Topic: 2

Visits by Source

User Actions

Users who voted for this posting

François
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)