CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 11/23/2005 10:54:45 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 286 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
Quango2005
Asp.Net User
Converting enum / nullable types11/23/2005 10:54:45 AM

0

The database field is int, NULL so my data layer property has Nullable(of Integer).

In my object class, I want to represent this as an Enum if it has a value, but how does one convert from Nullable(of Integer) to Nullable(of EnumType) ?

At present I have

Get
  If myBase.Field.HasValue Then
      Return New Nullable(Of EnumType)(mybase.Field.Value)
   Else
      Return Nothing
   End if
End Get

Which seems a little long-winded, when it perhaps ought to permit 

   Return CType(MyBase.Field, Nullable(Of EnumType))

howard
sbyard
Asp.Net User
Re: Converting enum / nullable types11/23/2005 11:51:08 AM

0

Enums are based on a value type and cannot be null

You can create a null value and assign this to represent a database null value.

E.g.

Enum
{
   Null=0,
   First,
   Second
}

You could also use generics to represent a null value type. see

http://msdn2.microsoft.com/en-us/library/b3h38hb0.aspx


If it was easy, everybody would be doing it.
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional C# 2005 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones, Pages: 1540, Published: 2005
PROFESSIONAL C# 2008 Authors: Bill Evjen, Christian Nagel, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1844, Published: 2008
Professional C# 2005 with .NET 3.0 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1748, Published: 2007
C# 2005 Programmer's Reference Authors: Adrian Kingsley-Hughes, Kathie Kingsley-Hughes, Pages: 386, Published: 2006
C# annotated standard Authors: Jon Jagger, Nigel Perry, Peter Sestoft, ScienceDirect (Online service), Pages: 825, Published: 2007

Web:
CodeProject: C# 2.0 Nullable Types. Free source code and ... Oct 3, 2005 ... General instructions on the use of nullable types in C#.; Author: Edward ... Using the nullable version of an enum is no different. .... Converting from standard to nullable is always implicit whereas conversions from ...
Converting enum / nullable types - ASP.NET Forums In my object class, I want to represent this as an Enum if it has a value, but how does one convert from Nullable(of Integer) to Nullable(of ...
Converting enum / nullable types - ASP.NET Forums Converting enum / nullable types. Last post 11-23-2005 6:51 AM by sbyard. 1 replies. Sort Posts: Oldest to newest, Newest to oldest ...
Nullable Enum nullable type question - Stack Overflow MyClassEnum = Convert.IsDBNull(x) ? MyEnum.None : (MyEnum) Enum.Parse(typeof( MyEnum), x. ... Best way to databind a Winforms control to a nullable type? ...
CodeProject: Converting CSV Data to Objects. Free source code and ... However it does not correctly handle Enums and Nullable Types (eg int?). ... SetValue(target, Convert.ChangeType(data, propertyType), null); ...

Converting enum / nullable types - ng.asp-net-forum.visual_studio_2005 Converting enum / nullable types, > ROOT > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005, Date: 11/23/2005 10:54:45 AM, ...
ASP.NET Development Server: Port in use (but it's not!) - ng.asp ... converting enum / nullable types ยท web site administration tool - only sql server database? updatepanel - controls hard to arrange in design ...






inadvertently removed an item from toolbox -- need to add it back

file path references

unable to read project file... you must install all of the following components...

visual studio 2005 and cassini

auto generated code issue

vs 2005 sql server 2005 express did not install

compile into dll

ide not showing custom control in vs 2005

how to start up visual c++...

accessing properties of buttons in a table layout

sourcesafe integration

vs 2005: solution issue

fckeditor

layout problem (design)

conditional compilation constants in 2.0 [beta 2]

trace after variables in vs 2005

february ctp : vs .net 2005 ctp fevrier :access is denied for the application you are attempting to administer

open a class file from another class

reading multiple rows from stored procedure (c#, asp.net)

how do you turn intellisense back 'on'

problem in installing vs.net 2005

vs 2005 won't stop debugging

property window shows the same control...

stop vs from compiling on compileerror

unable to open server explorer

xsd to vb

rss feed

need help ?...could not load assembly

visual studio v/s visual web developer

my first asp.net website

   
  Privacy | Contact Us
All Times Are GMT