Implicit Operator in C#

It’s fun learning something new that gives you the feeling of “wow, that’s pretty cool”.  The other day I was searching for some code to use Google Translator API.  I found some .NET project someone had written, but it didn’t work at all and the documentation, ironically, had malformed sentences making it hard to understand.  The one think I did see was a line like this “Language lang = “en-GB”.  At first glance, I thought, that’s odd how do the do that?  Then I looked at the meta data about the assembly class and noticed that class was using something called the implicit operator.  It’s a user-defined type.  There’s a really nice article on it’s usage on Code Project, Understanding Implicit Operator Overloading in C#.  Using this cool user-defined type, I wrote my own version of the Google translator API for .NET which can be found on SorceForge, DotNetGoogleTranslator.

No comments: