If I create a normal Console App with a normal Main entry point as follows
using System;
namespace ConsoleApp
{
public class Program
{
public static void Main(string[] args)
{
// do stuff
}
}
}
then select it in visual studio everything is fine..
However, if I write the code as follows...
using System;
namespace ConsoleApp
{
public class Program
{
public static void Main(String[] args)
{
// note the capital S in String
}
}
}
then everything is not fine....
Does anyone know why is it not picking up the String[] but happy with the string[] please ?
edit: Extracting from comments, it appears to be a bug in Visual Studio 2012 and 2013. Presumably it's also present in earlier editions but appears to have been rectified in VS2015. It's not a problem per se, and as noted the code still compiles and executes with either string[] or String[] I'd be interested to know the cause of the bug in VS though. I'd imagine the property editor window isn't Using System;
?
Are you sure your example that uses String
does actually compile?
Lowercase string
is a keyword that is equivalent to using System.String
; since your example doesn't import the System
namespace, I expect it will cause compilation errors which might result in the project properties not being able to identify your Main method.
Add a using System;
directive to the code file or explicitly use System.String
instead of String
to make the type known to the compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With