nutshell program driving me nuts.
Options
Hello: I am getting started. The first program I tried from the Nutshell book, A first C# program on page nine does not work. I get a "null reference exception". The program is OK, because I can compile and run it from the command prompt and besides, it is your program. Right now, this makes cmd easier to use than Linqpad. I have the Linqpad set to C# program. Oddly enough, I found if I comment the outer braces for the class; then it runs OK. Does this mean that Linqpad does not run regular programs? In other words, I can't just paste in programs?
By the way, I need two more characters to get my name to fit, can you increase the character count from twenty to twenty-two?
//using System; // Importing namespace
//class Test // Class declaration
{ // **** comment here
static void Main() // Method declaration
{
int x = 12 * 300; // Statement 1
System.Console.WriteLine (x); // Statement 2
} // End of method
} // End of class, ***** comment this line, and the matching one above, and it works.
By the way, I need two more characters to get my name to fit, can you increase the character count from twenty to twenty-two?
//using System; // Importing namespace
//class Test // Class declaration
{ // **** comment here
static void Main() // Method declaration
{
int x = 12 * 300; // Statement 1
System.Console.WriteLine (x); // Statement 2
} // End of method
} // End of class, ***** comment this line, and the matching one above, and it works.
Comments
-
Go to LINQPad's samples tab, click Download/import more samples, and click the C# 5.0 in a Nutshell library. You'll then see all the code listings from C# 5.0 in a Nutshell correctly set up for LINQPad, with notes on how LINQPad's Program and Statements modes work.
-
Your book is not thread safe. I had to pause the worker thread that was reading the book and start a new one to read the "read this first" in the samples. You could say I was having a thread lock, or something . . .
-
The instructions on downloading LINQPad samples are in the preface and also in Chapter 2. Are the instructions unclear? If so, I can improve them for the next edition!
Thanks.
Joe