Cannot implicitly convert type

C

Christoph Boget

There's no such concept as setting a variable to have no value. Even
No. Why would you want to?

Well, as it is no doubt apparent by now, I'm trying to conver Sql* data
types to c# data types. I'm doing this in a data access class that is
reading
(and writing) data to a datastore. When reading a new record, if that new
record has a NULL value in a column where the previous record had data,
I need a way to "unset" the value of the class' member variable that
represents
that column. And since I'm having issues converting, say, SqlString.Null to
a string (as was evidenced throughout this thread) I was just hoping that
there
was some other way to "unset" the variable.

thnx,
Christoph
 
J

Jon Skeet [C# MVP]

Christoph Boget said:
Well, as it is no doubt apparent by now, I'm trying to conver Sql*
data types to c# data types. I'm doing this in a data access class
that is reading (and writing) data to a datastore. When reading a new
record, if that new record has a NULL value in a column where the
previous record had data, I need a way to "unset" the value of the
class' member variable that represents that column. And since I'm
having issues converting, say, SqlString.Null to a string (as was
evidenced throughout this thread) I was just hoping that there was
some other way to "unset" the variable.

No - you need to have a value which represents NULL, basically -
whichis exactly what SqlInt.Null is for, but it only applies to the
SqlInt type.

The good news for you is that C# is going to get nullable value types
(I'm not sure at what performance/space penalty) - the bad news is that
Whidbey is still a fair way from being released.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top