473,804 Members | 3,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nullable types. why no support for nullable string

Hi,

I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.

Imagine a field (of type sting) in a database which is not assigned.

I agree with nullable only for value types but in my eyes string is kind of
a mix between a value type and a reference type.

Greetings,

Sakis
Nov 16 '05 #1
3 32281
Sakoulakis <sa********@pat hfinder.gr> wrote:
I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.
Um:

string s = null;
Imagine a field (of type sting) in a database which is not assigned.
Yup - so when you assign it to a string variable on the client, you
assign the variable a value of null. Where's the problem?
I agree with nullable only for value types but in my eyes string is
kind of a mix between a value type and a reference type.


No, string is a reference type, very definitely.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Sakis,

A string is a reference type. You can set a string variable to null, so
Nullable<string > is not needed.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sakoulakis " <sa********@pat hfinder.gr> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.

Imagine a field (of type sting) in a database which is not assigned.

I agree with nullable only for value types but in my eyes string is kind of a mix between a value type and a reference type.

Greetings,

Sakis

Nov 16 '05 #3
You're right.

Thanx
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Sakis,

A string is a reference type. You can set a string variable to null, so Nullable<string > is not needed.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sakoulakis " <sa********@pat hfinder.gr> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

I was just reading about nullable types and I like that feature very much. What dissapointed me is that nullable string is not supported.

Imagine a field (of type sting) in a database which is not assigned.

I agree with nullable only for value types but in my eyes string is kind

of
a mix between a value type and a reference type.

Greetings,

Sakis


Nov 16 '05 #4

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

Similar topics

1
2109
by: Riko Eksteen | last post by:
I would like to display nullable types in the propertygrid control. This usally requires a TypeConverter being implented for the specific type. For example, a BooleanConverter class will allow a True-False dropdown list to be displayed in the propertygrid. Beta 1 of C# 2.0 doesn't have type converters for the System.Nullable<T> type. It is therefore not possible for me to display my nullable bool and int values in the propertygrid. Will...
12
3648
by: Steven Livingstone | last post by:
I've just blogged some stuff on Nullable types in net 2.0. http://stevenr2.blogspot.com/2006/01/nullable-types-and-null-coalescing.html Question however as to why you can't simply get an implcit conversion from a ..Net value type to to a Sql Server data type rather than having to use null cheked and DBNull.Value ? Does anyone have some explanation as to why this is so tricky as to be included?
6
3845
by: Steven Livingstone | last post by:
Bit of advice here folks. I am creating a default constructor that just initializes a new instance of my object and a secon constructor that takes an ID and loads an object with data from the database for the given ID. I could just leave two separate constructors, or i could just have the default one call the second with a "-1" as the ID. This means that the initialization of certain fields can be based on whether my ID is -1 (for lazy...
0
1412
by: Larry Lard | last post by:
There seems to be something a bit lacking in the way the dataset designer thing deals (or rather doesn't) with nullable fields in VS2005. Maybe it's cos I'm using VB2005 Express (which is variously crippled), I don't know. But it seems to me obvious that there should be some way to specify that DB fields which can be null should be mapped to appropriate Nullable(Of T) generic types. For fields there's a dropdown in the dataset designer...
3
2271
by: MobileBoy36 | last post by:
Hi all, Nullable types were announced as new handy stuff in .NET 2.0 But it seems like the datareader doesn't support nullable types. You have still to check for "IsDbNull". So, are Nullable Types useful at this moment? Do you get any benefit using them (at this moment)? Is Microsoft going to change this? Best regards,
2
180
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 same is no point to use the longer declaration as 2 it good enough to use decaration 1.
6
1471
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 can also look at the value of a reference type using the Value property. If HasValue is true, then you are guarantee a non-null value for Value, but if HasValue is false, that is, null has been assigned to the variable, then accessing Value will
2
1183
by: Tony Johansson | last post by:
Hello! What purpose has this Value propery on nullable types because it possible to display their value without using it. For example: int? intNullable1 = 3; int? intNullable2 = 5; Console.WriteLine(result); // This display 8 Console.WriteLine(result.Value); // This also display 8 the same
3
2415
by: Tony Johansson | last post by:
Hello! Is it possible to declare existing .net generics to have nullable types(for example type int? ) ? If the answer on the previous question is yes then I assume that you can also define my own generics class having nullable types. //Tony
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.