Sign In
The Visual Basic Team
A group blog from members of the VB team Visual Basic Developer Center | How-Do-I Videos | Power Packs | Code Samples | Team Interviews | Team Webcasts
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
Amanda Silver
Beth Massi
Bill Horst
Did you know?
Doug Rothaus
IDE
I'm A VB!
Interview
Jonathan Aneja
Kit George
LINQ Cookbook
LINQ/VB9
Lisa Feigenbaum
Lucian Wischik
Matt Gertz
Pages
Scott Wisniewski
Silverlight
VB_Express
VB2005
VB2008
VB2010
VB6_Migration/Interop
WPF
XML
Archive
Archives
December 2011
(1)
November 2011
(3)
October 2011
(2)
September 2011
(3)
August 2011
(3)
June 2011
(2)
May 2011
(3)
April 2011
(7)
March 2011
(7)
February 2011
(5)
January 2011
(2)
December 2010
(1)
November 2010
(2)
October 2010
(1)
September 2010
(1)
June 2010
(5)
May 2010
(2)
April 2010
(3)
March 2010
(1)
February 2010
(2)
January 2010
(3)
December 2009
(2)
November 2009
(6)
October 2009
(51)
September 2009
(3)
August 2009
(2)
July 2009
(55)
June 2009
(53)
May 2009
(13)
April 2009
(8)
March 2009
(13)
February 2009
(7)
January 2009
(3)
December 2008
(28)
November 2008
(25)
October 2008
(24)
September 2008
(16)
August 2008
(8)
July 2008
(6)
June 2008
(7)
May 2008
(10)
April 2008
(3)
March 2008
(20)
February 2008
(4)
January 2008
(14)
December 2007
(18)
November 2007
(19)
October 2007
(11)
September 2007
(12)
August 2007
(9)
July 2007
(21)
June 2007
(18)
May 2007
(12)
April 2007
(14)
March 2007
(15)
February 2007
(2)
January 2007
(6)
November 2006
(3)
October 2006
(3)
September 2006
(4)
July 2006
(1)
June 2006
(3)
April 2006
(2)
March 2006
(1)
January 2006
(1)
December 2005
(2)
November 2005
(10)
October 2005
(1)
September 2005
(6)
July 2005
(7)
June 2005
(4)
May 2005
(1)
April 2005
(7)
March 2005
(3)
January 2005
(2)
November 2004
(2)
October 2004
(2)
September 2004
(1)
August 2004
(7)
July 2004
(6)
June 2004
(1)
May 2004
(9)
Nullable types in VB as Well
MSDN Blogs
>
The Visual Basic Team
>
Nullable types in VB as Well
Nullable types in VB as Well
VBTeam
28 May 2004 8:08 AM
Comments
19
Eric Gunnerson
writes about C# supporting Nullable types.
We've heard a lot of positive feedback on the Nullable types. Just so everyone's aware, this is NOT a C# specific feature. Just as with all generics, VB will both emit and consume the full set of generics, including Nullable types.
VB has a slightly different syntax, and is a little easier to type as the VS Whidbey Code Editor will auto expand the body:
If I have an Order object that has a DateShipped property, it would be expressed as:
Public Class Order
Public Property OrderId as Integer
…
Public Property DateShipped as Nullable(Of DateTime)
…
When the user types Nullable and hits tab, VB will automatically add “(Of “. It just reads more cleanly. Even reading C#, I would read Nullable Of DateTime. Now, C# is doing a bit of syntactical sugar and using ? in their syntax as well as Nullable
Public class Order
public int OrderId {get/set}
public DateTime? DateShipped {get/set}
It is a little strange that VB was historically criticized for supporting multiple ways to do the same thing, and confusing users which was the best. How about + &.
This becomes especially useful when working with Databases and ADO.net
Some of the features we’re considering in Beta 2 are the ability to leverage Nullable(Of T) on our new TableAdapter methods. In the Beta 1 product, as well as the Community Technology Previews you’ll see methods generated insert, update, delete and fill. These have two method signatures. One strongly typed, and one with the same number of parameters that take object as their type. This was to support sending Null into the methods. Unfortunatley, this means you won’t get any compile time errors if you pass a string for a column that requires int. We are looking at moving these overloads to a single method signature:
Public Function Insert(ByVal id As Nullable(Of Integer), ByVal name As String, ByVal dateClosed As Nullable(Of DateTime)) As Integer
If dateClosed.HasValue Then
Me.InsertCommand.Parameters(0).Value = dateClosed.Value
Else
Me.InsertCommand.Parameters(0).Value = System.Convert.DBNull
End If
Steve Lasker
Program Manager
Visual Basic Data
19 Comments
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 1 and 3 and type the answer here:
Post