Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how many classes do I need to import?

Status
Not open for further replies.

adonet

MIS
May 4, 2004
312
US
How to determine what class do I need to import? The more the better? What are the basic class I need to import?
 
adonet,
You need to import only the namespaces that you will need in your application. Importing more than needed simply hurts application performace. The one namespace you will need for all your apps is System. Asides from that, the namespaces you will import will depend on the kind of application you'll be building. For example, for database applications, you will need the types in the System.Data namespace. If you'll be building a Windows Forms (GUI) application, you'll need the System.Windows.Forms namespace, and so on. Again, you should only import the namespaces that contain types you will need in your application.

If you don't know the namespace of a type you want to use, there is a very nice tool that comes with the .NET SDK that allows you to do a search on such type. The tool is called WinCV.EXE (short for Windows Class Viewer) and its found in the "C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin" folder.

Hope this helps!

JC

Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
Thank you. I learned a lot. One more question, any utility to find method?
 
Is there anything in .NET to include all the subclasses inside a package instead of including each one seperately as we have in java import java.awt.*;
 
adonet,
I think WinCV allows you to search for methods as well, that, but I'm not sure. If not, you may try the MSDN Library which should be your best friend when starting out. If you don't have MSDN on your computer, you may use it online at - Hope this helps!

rsubras,
In .NET, you always include all the subclasses inside packages. You don't have the option to include individual types; you only have the option to include all types in a package. By type, I mean any of the following: class, structure, interface, delegate, or enumeration. Also, packages are called namespaces in the .NET world. Thus, in .NET for example, you would import the System.Data namespace, or the System.Windows.Forms namespace. Hope this helps!

JC

Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
probably my question wasnt clear JC...

like

include System.Web.UI does not automatically include System.Web.UI.WebControls rite? or am i wrong?
 
rsubras,
Including System.Web.UI DOES include System.Web.UI.WebControls but, in order for you to use the types in the WebControls namespace, you would have to preceed them with the word WebControls, as in:

WebControls.Label myLabel = new WebControls.Label(...);

As far as I know, there isn't any way to automatically inlclude all the namespaces within a namesapce. Thus, in order for you to use the types in the WebControls namespace without preceeding them with the word WebControls, you would have to include the WebControls namespace separately, as in:

include System.Web.UI;
include System.Web.UI.WebControls;

Hope this helps!

JC

Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top