Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

My question is to do with the datatype?

In the constructor of a class, I am initializing the variables which are of various types (i.e: string, double, decimal, etc...)

These are initialized such as "" for string and 0 for int or 0 for double, etc...

Let's say that during a call to the DB, only one of them gets set (i.e: the string variable = "hello") but the other variables are not set. So obviously the other variables are set to 0 of they are decimal for example.

The question is that how is it possible to find out that the other variables that were not set?. I.e: how can I return null for the other variables?

 

Hope this is clear

Thanks

Farshad
Posted

I am not quiet sure that I understand your question.

 

What I get is that you wish to have variables that return only values when they are assigned, and otherwise Null.

 

How about if you don't assign a default value to them and declare them at the beginning of the class, like:

 

Private myVariable as String

Private myOtherVar as Double

 

Now, in case of a db call, only assign values to the ones that do not have a dbNull return (test for "Not IsDbNull").

 

All other variables should have a value of Nothing at this point.

 

Does that help?

IS

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...