null is unrecognized literal

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?
 
D

doofy

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.
 
D

doofy

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?
 
C

Chris Shepherd

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.
 
A

Adrian

..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.
 
D

doofy

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You select the language when you create the project.

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

doofy

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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
 
B

Ben Voigt [C++ MVP]

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top