Sharing the information you need to get development done!
Welcome to DevAuthority.Com Sign in | Join | Help
in Search

Confessions of a Webgypsy

.Net 2.0 Operators

So I'm following up with some of the comittments I made back in May.  I've begun working again to organize Code Camp Cleveland (more on that soon) and I've started a push to get my Certifications.

So I've been starting to study for my first exam and ran accross a quick blurb in the materials about the new Operators in .Net 2.0.  I realize that we are now onto 3.0 and 3.5 will be here before we know it, but somehow I missed this whole concept when 2.0 came out.  I am looking for some more information on it.  Is anyone using them?  What are your experiences?  Does anyone know of any good articles that explain them in more depth? 

Published Wednesday, August 15, 2007 5:18 AM by dbalzer
Filed Under:

Comments

 

DevPrime said:

Well, first we have to realize that MS did a very poor job of maintaining version semantics here, so there's bound to be some confusion. What we call ".NET 2.0" comes with a Framework 2.0, and was shipped with VS2005. What we call ".NET 3.0" still uses Framework 2.0 (and VS2005), but adds WF, WPF, and WCF components. What we will eventually call ".NET 3.5" uses a new framework, and will be released with VS2008.

Operators, being more tied to the VS languages than to the frameworks, really have little to do with the version numbers now. For example, 3.0 has nothing new in the way of language features because it's still part of VS2005.

As far as that goes, the languages (C# and VB) have both added quite a bit, but there really isn't much that's new with regards to operators.

C# has a :: operator and a ?? operator now.
:: is used to disambiguate global namespaces from aliased namespaces. Personally, I haven't really seen it used in more than one project. ?? is used to return a value in case of NULL, and is usually used with nullable types (but doesn't have to be). For example:

int? x;   // nullable integer variable called X
x = null;   // assign value NULL to X
int y;   // integer variable called Y
y = x ?? -1;  // y = value of X, or -1 if X is null

VB didn't add much to operators either. The only one I can think of is IsNot. This came from a long discussion with the MVPs, where it was clear that a ton of code did this:
If Not X Is Nothing...
but it makes more sense to write it as:
If X IsNot Nothing...

VB also added Operator overloading, which allows to define how various operators work when applied to your custom classes. But that's not really adding new operators. We will see more new operators in VS2008 (for both languages), but that's pretty much it for now.

Was there anything in particular that you were thinking of?
September 11, 2007 5:19 PM
Anonymous comments are disabled







This Blog

Post Calendar

<August 2007>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

Syndication



Powered by Community Server, by Telligent Systems