65873 members! Sign up to stay informed.

Sponsored Links


Resources

.NET Research Library
Get .NET related white papers, case studies and webcasts

News News News Messages: 9 Messages: 9 Messages: 9 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Microsoft Adds New Support for Nullable Types in .NET 2.0

Posted by: Thibaut Barrere on August 23, 2005 DIGG
Microsoft has added a last minute change to the implementation of Nullable types in .NET 2.0. This change allows for simpler null checks when using boxed references and generics. This new feature also provides the ability to coerce a nullable type to an interface implemented by the enclosed type.
The outcome is that the Nullable type is now a new basic runtime intrinsic. It is still declared as a generic value-type, yet the runtime treats it special. One of the foremost changes is that boxing now honors the null state. A Nullabe int now boxes to become not a boxed Nullable int but a boxed int (or a null reference as the null state may indicate.) Likewise, it is now possible to unbox any kind of boxed value-type into its Nullable type equivalent.

Read more at Somasegar's Weblog

Threaded replies

·  Microsoft Adds New Support for Nullable Types in .NET 2.0 by Thibaut Barrere on Tue Aug 23 07:52:15 EDT 2005
  ·  big fat mistake by peter lin on Tue Aug 23 11:33:57 EDT 2005
    ·  Is there a difference? by Mike Griffin on Tue Aug 23 13:52:14 EDT 2005
      ·  int? by Kevin Lewis on Tue Aug 23 18:59:14 EDT 2005
        ·  int? by Mike Griffin on Wed Aug 24 00:16:16 EDT 2005
          ·  It's only in the Runtime... by Cornelius van Berkel on Wed Aug 24 04:45:14 EDT 2005
            ·  It's only in the Runtime... by Mike Griffin on Wed Aug 24 09:56:12 EDT 2005
            ·  It's only in the Runtime... by peter lin on Wed Aug 24 12:21:01 EDT 2005
              ·  Very good news by Ruslan Zenin on Fri Aug 26 12:24:31 EDT 2005
  ·  Microsoft Adds New Support for Nullable Types in .NET 2.0 by Star Trooper on Thu Aug 25 08:46:48 EDT 2005
  Message #182205 Post reply Post reply Post reply Go to top Go to top Go to top

big fat mistake

Posted by: peter lin on August 23, 2005 in response to Message #182172
I can't help but feel this feature is ripe for abuse and unmaintainable code. When some other programmer has to fix or patch the code, how long is it going to take to figure out what it means. I really wish Microsoft would push for better coding and development practices and less on questionable features. Having spent lots of time fixing really aweful code, I can see the rampant abuse now.

I'm sure plenty of people will disagree.

peter

  Message #182224 Post reply Post reply Post reply Go to top Go to top Go to top

Is there a difference?

Posted by: Mike Griffin on August 23, 2005 in response to Message #182205
I've looked at the syntax in the blog post but I am failing to see any change at all in the syntax, either that or I need to go back and re-read it. Was the change just in the hidden boxing/unboxing stuff?

  Message #182244 Post reply Post reply Post reply Go to top Go to top Go to top

int?

Posted by: Kevin Lewis on August 23, 2005 in response to Message #182224
Instead of "int" you have "int?".

  Message #182249 Post reply Post reply Post reply Go to top Go to top Go to top

int?

Posted by: Mike Griffin on August 24, 2005 in response to Message #182244
Ya, but that was always the case, for like a year now?

  Message #182259 Post reply Post reply Post reply Go to top Go to top Go to top

It's only in the Runtime...

Posted by: Cornelius van Berkel on August 24, 2005 in response to Message #182249
<Quote>
Once an instance of the type was boxed (by casting to the base ‘Object’ type), it became a boxed value type, and no matter what its original ‘null’ state claimed, the boxed value-type was never null.
</Quote>

They tweaked the runtime behaviour of the generic Nullable struct, so that when the HasValue field is false and you assign it to a variable ot type object, this variable will be null, which is good, instead of being a boxed instance of that nullable type which is null...

Therefore I think this change is very nice and intuitive.
Big up for the guys fixing this...

  Message #182301 Post reply Post reply Post reply Go to top Go to top Go to top

It's only in the Runtime...

Posted by: Mike Griffin on August 24, 2005 in response to Message #182259
I agree, big up, didn't know the issue existed however. Anyway, it works now how it should ...

  Message #182328 Post reply Post reply Post reply Go to top Go to top Go to top

It's only in the Runtime...

Posted by: peter lin on August 24, 2005 in response to Message #182259
<Quote>Once an instance of the type was boxed (by casting to the base ‘Object’ type), it became a boxed value type, and no matter what its original ‘null’ state claimed, the boxed value-type was never null.</Quote>They tweaked the runtime behaviour of the generic Nullable struct, so that when the HasValue field is false and you assign it to a variable ot type object, this variable will be null, which is good, instead of being a boxed instance of that nullable type which is null...Therefore I think this change is very nice and intuitive.Big up for the guys fixing this...

ok.. that makes much more sense. I retract my statement about it being a big mistake. though the blog and article both did a horrible job explaining it. not that I haven't horrible articles myself, but it would be better to have a clearer explanation.

peter

  Message #182426 Post reply Post reply Post reply Go to top Go to top Go to top

Microsoft Adds New Support for Nullable Types in .NET 2.0

Posted by: Star Trooper on August 25, 2005 in response to Message #182172
Why is the fuss with this very basic feature? Man, I can hardly believe the happiness and ectasis people is now feeling about being able to have a "Nullable Object"

As for myself... I'll stick to using the NullableObjects framework from SourceForge. It has solved my problems for more than 1.5 years by now.

Good luck!

  Message #182622 Post reply Post reply Post reply Go to top Go to top Go to top

Very good news

Posted by: Ruslan Zenin on August 26, 2005 in response to Message #182328
We have had discussed this ability for primitive types on Java thread here:
http://www.theserverside.com/discussions/thread.tss?thread_id=30463

I wish such feature would be included into next release of Java...

Recent active threads Recent active threads Recent active threads More More More
[Volumes]:Buy and Sell Blackberry 8830 Housing
Transferring current project to Mysql
biztalk workflow/rule engine
I need solutions for below questions
How to data binding ADO.NET DataSet Access or SQL Server DB...
RazorSQL SQL Editor and Database Query Tool Available
Service Pack 2 for TX Text Control RapidSpell .NET 15.0 released
How to create dynamic Folded Corners effect through ImageDraw im
An Evaluation of Windward Reports
More active threads »
Top posters of the weekTop posters of the weekTop posters of the week
This list contains the members who have made the most posts in all forums over the last 7 days:
  1. muthya prasad
  2. SHERRYSLC SHERRYSLC
  3. Richardson Software
  4. Guru Talend
  5. Neodynamic Components
Hot threads Hot threads Hot threads More hot threads More hot threads More hot threads

Eclipse vs. Visual Studio at EclipseCon 2006

Speaking at EclipseCon 2006, Java developer and independent consultant Madhu Siddalingaiah compared Microsoft's Visual Studio IDE to the open source development environment of Eclipse.
(33 comments, last posted July 13, 2009)

Tech Talk: Peter Provost on CAB and Agile development

In this tech talk, Microsoft's Peter Provost talks about the design of the Composite UI Application Block and how the p&p team has led Microsoft in the adoption of Agile methodologies.
(0 comments, last posted April 17, 2006)

Book excerpt: Framework Design Guidelines

Chapter 4 of Framework Design Guidelines, titled "Type Design Guidelines," presents patterns that describe when and how to design classes, constructs and interfaces. In this chapter, Abrams and Cwalina divide types into four groups and discuss the do's and don'ts of type design.
(2 comments, last posted July 07, 2006)

Q&A: Miguel "Mono Man" De Icaza

Paul Ferrill caught up with prime open-source .NET applications driver Miguel De Icaza at Novell's BrainShare conference last week. They discussed the status of Windows Forms for Mono (it's coming along) and VB.NET for Mono (it looks like it's out).
(5 comments, last posted March 30, 2006)

Tech Talk: Jack Greenfield on software factories and DSLs

In this tech talk, Microsoft Visual Studio architect Jack Greenfield discusses the company's approach to Domain-Specific Languages, or DSLs, and the part they play in software factories.
(0 comments, last posted March 15, 2006)
More hot threads »

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
All Content Copyright ©2007 TheServerSide Privacy Policy      Powered by JIVE
Site Map