null is unrecognized literal

  • Thread starter Thread starter doofy
  • Start date Start date
D

doofy

I'm trying to run some code I typed in from "Pro .Net 2.0 Windows Forms
and Custom Controls in C#", and I'm getting two errors that seem like
they shouldn't be happening.

One example is:

if (mc == null) [where mc is a reference to Quartz.dll, which I
pulled in by letting VS 2008 do an interop]

It gives me something like "null is an unrecognized literal".


Next one is:

if (mc.ShowDialog() == DialogResult.OK)

it comes back and says "OK is unrecognized Enum"

Is there some namespace I need to pull in to make these work?
 
Ignacio said:
Hi,

No, ar eyou sure u r creating a C# project?

I wondered about that. I'm new to both C# and VS 2008. I set the
settings for C#. It's accepting curly braces in the code where C++
would use a parenthesis.
 
Ignacio said:
Hi,

No, ar eyou sure u r creating a C# project?

So, I've specifically set the environment to C#, and I'm getting files
that are generated with the .cpp file type. Does this happen in C# also?
 
doofy said:
So, I've specifically set the environment to C#, and I'm getting files
that are generated with the .cpp file type. Does this happen in C# also?

C# files are generally .cs, it sounds like your project is a C++ project.

Chris.
 
..cpp files are C++ files. C# files have a .cs file extension. When you create
the project you have to choose what language you want to use.
 
Adrian said:
.cpp files are C++ files. C# files have a .cs file extension. When you create
the project you have to choose what language you want to use.

:

I thought I did. A few times. However, I went to my other machine and
created the project, and I've got .cs files now, and the code is working
fine. Sorry for the newbie hiccup.
 
Hi,

You select the language when you create the project.

Not only that, but IIRC null is also a valid keyword in C++
 
Ignacio said:
Hi,

You select the language when you create the project.

Not only that, but IIRC null is also a valid keyword in C++

Evidently, when my project window was opening for C#, the cursor was way
down in the "Other Languages" area, and I didn't notice. Thus my
blunder. Now I know. Null is still a mystery in C++ then. But it's
working in CS.

Thanks for the help all. It made me start thinking outside the box.
 
Hi,



doofy said:
Ignacio Machin ( .NET/ C# MVP ) wrote:
Evidently, when my project window was opening for C#, the cursor was way
down in the "Other Languages" area, and I didn't notice. Thus my blunder.
Now I know. Null is still a mystery in C++ then. But it's working in CS.

As C# and C++ are both case sensitives you have to use null , in lowercase.
Maybe that was your error all the time
 
Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

You select the language when you create the project.

Not only that, but IIRC null is also a valid keyword in C++

No, it's not. NULL is a symbolic constant for (address) 0, while "nullptr"
is the new C++/CLI keyword which looks like it will be standardized in
C++0x.
 
Hi,

My bad, it's been a while since I last touched C++

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Ben Voigt said:
Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

You select the language when you create the project.

Not only that, but IIRC null is also a valid keyword in C++

No, it's not. NULL is a symbolic constant for (address) 0, while
"nullptr" is the new C++/CLI keyword which looks like it will be
standardized in C++0x.
 
Back
Top