Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using image and also color i my application.
and i am using namespace as bellow:
C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Drawing.Imaging;
using System.Drawing;


Now it shows error. if i remove
C#
using System.Drawing;

then error shows in color block and if i remove
using System.Drawing.Imaging;
this namespace then error shows in image block.
So which namespace is actual reqired for both.
Posted

Use the required namespace.
For e.g. if there is a class A that belongs to namespace N1 and N2 here is what you could do -
N1.A myObjectForN1 =  new N1.A();
N2.A myObjectForN2 =  new N2.A();
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 14-Jul-15 11:15am    
5ed, but there is a bit more about it.
Please see Solution 2. Your solution is credited.
—SA
Abhinav S 14-Jul-15 12:03pm    
Thanks.
In addition to Solution 1:

First of all, make sure you really need both types in the same file. It may happen that one is just a remnant of old code. With Visual Studio, it's always useful to do this: show popup menu in the code editor and use "Organize Usings" => "Remove Unused Usings". Don't overuse "using". :-)

But it's possible that you really use both types in one code file. So, namespaces…

Now, understanding of namespaces is one of the basics things you need. You cannot do any programming without full understanding. The error message tells you clearly what's wrong. You just need to read on the topic: .

In addition to the technique showed in Solution 1, you can use alias using directive (not to be mixed up with using statement!): https://msdn.microsoft.com/en-us/library/sf0df423.aspx[^]:
C#
using WebImage = System.Web.UI.WebControls.Image;
using DrawingImage = System.Drawing.Image;

//...

WebImage image = //...

//...

DrawingImage image = //...

You can choose any of the ways, or combine them, depending on your sense of readability and personal taste.

—SA
 
Share this answer
 
Comments
Member 11221185 15-Jul-15 2:06am    
Thanks
Sergey Alexandrovich Kryukov 15-Jul-15 2:20am    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900