IMHO I thought string was a value type which can not be null . I dont know what would happen If you set it to null. Generally you should initialize to String.Empty;
Ben -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]]On Behalf Of Richard Blewett Sent: Thursday, 19 September 2002 6:38 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Funny in Visual Studio? yep, I checked it and also if you do class App { static void Main(string[] args) { StringTest s = new StringTest(); if(s.MyString == null) Console.WriteLine("Its really null"); if( s.MyString == "" ) Console.WriteLine("Its really blank"); } } public class StringTest { private string _myString = null; public string MyString { get { return _myString; } } } s.MyString is definitely null so its a bug in the watch window. As it happens I was sitting next to a guy from MCS when I checked this so he's logging it as a bug Richard Blewett DevelopMentor -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]]On Behalf Of Simon Hewitt Sent: 19 September 2002 11:08 To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] Funny in Visual Studio? public class StringTest { private string _myString = null; public string MyString { get { return _myString; } } } In VS.Net, if I create an instance of the above class and then view it in the Watch Window, _myString returns Value=null which is as expected. MyString returns Value="" which is not correct. Is this a bug? Or am I missing something. Cheers Simon You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
