473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

System.Nullable 2.0 Framework

The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want multiple
call lines to the one method, just one.

--
Goofy

--
Goofy
Dec 20 '06 #1
4 3769
Got it

Dim year As System.Nullable(Of Single)

Dim week As System.Nullable(Of Integer)
"Goofy" <me@mine.comwrote in message
news:%2*******************@TK2MSFTNGP06.phx.gbl...
The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want multiple
call lines to the one method, just one.

--
Goofy

--
Goofy

Dec 20 '06 #2
"Goofy" <me@mine.comwrote in message
news:uM**************@TK2MSFTNGP06.phx.gbl...
Got it

Dim year As System.Nullable(Of Single)

Dim week As System.Nullable(Of Integer)
Not sure about VB.NET, but in C# v2 you can do this simply by appending a
question mark to the datatype e.g.

Int32 intYear = 0; // not nullable
Int32? intYear = null; // nullable
Dec 20 '06 #3
Didnt know that, but then I dont code in C# normally. This nullable facility
is really usefull in some situations I find.

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:ut*************@TK2MSFTNGP02.phx.gbl...
"Goofy" <me@mine.comwrote in message
news:uM**************@TK2MSFTNGP06.phx.gbl...
>Got it

Dim year As System.Nullable(Of Single)

Dim week As System.Nullable(Of Integer)

Not sure about VB.NET, but in C# v2 you can do this simply by appending a
question mark to the datatype e.g.

Int32 intYear = 0; // not nullable
Int32? intYear = null; // nullable

Dec 21 '06 #4
"Goofy" <me@mine.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Didnt know that, but then I dont code in C# normally.
Conversely, I never go anywhere near VB.NET... :-)
This nullable facility is really usefull in some situations I find.
I couldn't agree more! One of the most important enhancements in v2, along
with generics.
Dec 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ESPNSTI | last post by:
Hi, Please don't shoot me if the answer is simple, I'm new to .Net and C# :) .. I'm attempting to convert a nullable type to it's "non-nullable" type in a generic way (without knowing what...
0
by: pranesh.nayak | last post by:
Hello Group, (tech: C#, VS2005) I'm facing a problem in passing Nullable<DateTimeto a webservice. Below is code in webservice wrapper (reference.cs) used set/get date. When i set date value...
5
by: GG | last post by:
I am trying to add a nullable datetime column to a datatable fails. I am getting exception DataSet does not support System.Nullable<>. None of these works dtSearchFromData.Columns.Add( new...
8
by: Sam Kong | last post by:
Hello, I want to define a generic class which should accept only nullable types or reference types. What's the best way to costrain it? --------- class MyClass<T>{ ...
3
by: Goofy | last post by:
The 2.0 Framework has a new type called System.Nullable. This allows something to Not exist, basically you can pass 'Nothing' to a method whose parameters as System.Nullable. Im looking at table...
1
by: Dan Holmes | last post by:
i need to get an object of type Type when i have a string. That is the easy part (Type.GetType("int")). What if i want that type to be nullable? This doesn't work Type.GetType("int?"). It...
2
by: Tony Johansson | last post by:
Hello! These two declarations(1 and 2) are the same I assume. 1. System.Nullable<intnullable; 2. System.Nullable<intnullable = new System.Nullable<int(); So because these 1 and 2 are the...
6
by: Tony Johansson | last post by:
Hello! I'm reading in a book called Visual C# 2005. In the chapter about Generics there ia a section about Nullable types. Here is the text that isn't complete true I think. It says: "You...
8
by: Tony Johansson | last post by:
Hello! Jon skeet answer this question in a previous mail for several days ago if nullable type is a reference or a value type? With the following answer. It's a struct - otherwise there'd be...
2
by: jon.rea | last post by:
Please tell me there is a better way :-D .... public static bool IsNullableType(Type paramType) { return paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.