Just a quick question for the VisualStudio 2008 compiler.
We really included that warning compilers are seen as errors that work fine, but today I found out that the following behavior:
static void Main(string[] args) { int number = 0; DateTime dateTime = DateTime.Now; }
Compiling this fragment leads to only one warning: "The variable" number "is assigned, but its value is never used."
Can someone explain the difference to me why a variable causes an error, but not a dateTime variable?
Well, it looks like this has something to do with literals. Given the following code:
static void Main(string[] args) { string str1 = "Foo"; string str2 = str1; }
Compiling with both lines does not result in a warning, although the variable str2 is never mentioned. If you comment on the string string str2 = str1; , a warning appears for the variable "str1" is never used.
source share