473,403 Members | 2,366 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,403 software developers and data experts.

private const string s = "" yields null?

Hi,

Did anybody notice that the following declaration of a member const

public class Tubo
{
private string const def = "";
}

is alyways null instead of empty string ("")?

Is this a bug or feature or something else?

Thanks,
Miha
miham at spin dot si
Nov 15 '05 #1
3 4286
Duh, it is only the debugger reporting it as null.
It is correctly set to "".

Miha

"Miha Markic" <ms**@spin.si> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
Hi,

Did anybody notice that the following declaration of a member const

public class Tubo
{
private string const def = "";
}

is alyways null instead of empty string ("")?

Is this a bug or feature or something else?

Thanks,
Miha
miham at spin dot si

Nov 15 '05 #2
string.Empty is the preferred way to do it but "" will work as well
"Miha Markic" <ms**@spin.si> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Duh, it is only the debugger reporting it as null.
It is correctly set to "".

Miha

"Miha Markic" <ms**@spin.si> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
Hi,

Did anybody notice that the following declaration of a member const

public class Tubo
{
private string const def = "";
}

is alyways null instead of empty string ("")?

Is this a bug or feature or something else?

Thanks,
Miha
miham at spin dot si


Nov 15 '05 #3
Hi William,

string.Empty won't work for constant declaration.

Miha

"William Ryan" <do********@nospam.comcast.net> wrote in message
news:Oe****************@TK2MSFTNGP12.phx.gbl...
string.Empty is the preferred way to do it but "" will work as well
"Miha Markic" <ms**@spin.si> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Duh, it is only the debugger reporting it as null.
It is correctly set to "".

Miha

"Miha Markic" <ms**@spin.si> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
Hi,

Did anybody notice that the following declaration of a member const

public class Tubo
{
private string const def = "";
}

is alyways null instead of empty string ("")?

Is this a bug or feature or something else?

Thanks,
Miha
miham at spin dot si



Nov 15 '05 #4

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

Similar topics

5
by: Lecture Snoddddgrass | last post by:
Back in the old Visual C++ days, it was always important to define constant strings only once so that they wouldn't be stored over and over again in memory. Has .NET resolved this issue? Consider...
10
by: dcrespo | last post by:
Hi all, How can I replace all None values with the string 'Null' in a dictionary? For example: convert this: a = {'item1': 45, 'item2': None} into this:
0
by: Dana | last post by:
I am using the XMLTextWriter to build an XML string and pass it to the XMLDocument. When I get the data from SQL Server, some of the values passed to the XML are NULL in the database. When I try...
2
by: Rouben Rostamian | last post by:
The main() function in the following code defines an m by n matrix, assigns value(s) to its elements, then passes the matrix to function foo(). For whatever it's worth, I have declared foo() so...
3
by: Jordan Taylor | last post by:
I am confused about protected member functions and objects. Is there any particular advantage of declaring members protected?
3
by: coala | last post by:
In Smart Pointer class, we have a piece of code: inline void release(void) const { if (mPtr) mPtr->release(); mPtr = 0; } It can set mPtr but it is still const? Why could this work and why...
1
by: coala | last post by:
In Smart Pointer class, we have a piece of code: inline void release(void) const { if (mPtr) mPtr->release(); mPtr = 0; } It can set mPtr but it is still const? Why could this work and why...
16
by: Chris | last post by:
Looking at some code I see a declaration inside a function like static const string s("some string"); Does the static serve any purpose here?
7
by: Luna Moon | last post by:
Hi all, I just couldn't get myself clear about the usage of "const" in front of and/or behind variables, pointers, classes, objects and functions... It's too confusing... any good clear...
6
by: .rhavin grobert | last post by:
hello;-) i frequently need the following construction: ReturnParam § Function() § { /...do something.../ someType var § = something; /...do something.../ return something;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.