The type or namespace name 'Net' could not be found

A

Al Cadalzo

I get the compile error:
"The type or namespace name 'Net' could not be found"
on this line of code:

Net.HttpWebResponse resp = null;

Here are my using directives:
using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;

If I say 'System.Net.HttpWebResponse' then the error goes away.

I have a similar problem when I declare a SqlConnection

If I say SqlClient.SqlConnection I get the error, but If I say just
'SqlConnection' then it's OK.
It seems as though the 'using System' directive and the 'using System.Data'
directive are being ignored.

I assembly references to System, System.Data and System.XML.

I don't have any problem with the 'using System.IO;' directive.

Any ideas?

Thanks,
Al
 
J

Jon Skeet [C# MVP]

Al Cadalzo said:
I get the compile error:
"The type or namespace name 'Net' could not be found"
on this line of code:

Net.HttpWebResponse resp = null;

Yes. That's because the "using" statement doesn't mean you can use
partial *namespaces*, it just means you can use unqualified type names.

Just include:

using System.Net;

and then just use

HttpWebResponse resp = null;
 
A

Al Cadalzo

Jon,

Thanks alot. I guess it works a bit differently than the imports directive
I'm used to in VB.Net.

Al
 

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