USING statement

A

arr uba

Hi all,

as a newbye I understand many of my questions may seem awkwards to many of
you, but sometimes you just can't find quick answers even when browsing
several books on the subjects....(of course that depends on the books you
are reading).

With Intelisense you have access to the objects lists and others, but i
can't see any indication of the "using..." statement associated with them.

An example: in order to use OpenFileDialog object I copyied code from MVC#5
Offline Help, like this:


private void openProjectToolStripMenuItem_Click(object sender, EventArgs e)

{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
....
{
myStream.Close();
}}


When debugging I get the following error message:

Error 1 The type or namespace name 'Stream' could not be found (are you
missing a using directive or an assembly reference?) C:\...\Form1.cs

So, what is this namespace? Is there any direct way to identify it?
To solve this I picked-up from (another) example code and add it to my code,
like this:

using System.IO;

using System.Threading;

using System.Runtime.InteropServices;

using System.Runtime.Remoting.Messaging;



Result? It works ! The point is I don't know if I was just lucky because I
picked-up the right (other) example...
 
P

Paul

System.IO

Use the Object Browser (View>Object Browser) or do a MSDN search.

You really need a book on framework basics before you dive into Win Forms or
Web Forms.
 
P

Paul

System.IO

Use the Object Browser (View>Object Browser) or do a MSDN search.

You really need a book on framework basics before you dive into Win Forms or
Web Forms.
 
A

arr uba

Thanks!

Paul said:
System.IO

Use the Object Browser (View>Object Browser) or do a MSDN search.

You really need a book on framework basics before you dive into Win Forms
or Web Forms.
 
A

arr uba

Thanks!

Paul said:
System.IO

Use the Object Browser (View>Object Browser) or do a MSDN search.

You really need a book on framework basics before you dive into Win Forms
or Web Forms.
 
M

Marcel Overweel

arr uba said:
Hi all,

as a newbye I understand many of my questions may seem awkwards to many of
you, but sometimes you just can't find quick answers even when browsing
several books on the subjects....(of course that depends on the books you
are reading).

With Intelisense you have access to the objects lists and others, but i
can't see any indication of the "using..." statement associated with them.

An example: in order to use OpenFileDialog object I copyied code from
MVC#5 Offline Help, like this:


private void openProjectToolStripMenuItem_Click(object sender, EventArgs
e)

{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
...
{
myStream.Close();
}}


When debugging I get the following error message:

Error 1 The type or namespace name 'Stream' could not be found (are you
missing a using directive or an assembly reference?) C:\...\Form1.cs

So, what is this namespace? Is there any direct way to identify it?
To solve this I picked-up from (another) example code and add it to my
code, like this:

using System.IO;

using System.Threading;

using System.Runtime.InteropServices;

using System.Runtime.Remoting.Messaging;



Result? It works ! The point is I don't know if I was just lucky because I
picked-up the right (other) example...

Hi,

if the assembly where the class recides is already in the 'References' list
(in the solution explorer), you could place the caret between one of the
characters of the typename in your code and a small rectangle will appear
just below the last character. In your case, just below the 'm' from
'Stream'.

If you point it with your mouse, an option combo will appear where you
can select for "using ...." and it will add the using clause to your
project.

regards,
Marcel
 
M

Marcel Overweel

arr uba said:
Hi all,

as a newbye I understand many of my questions may seem awkwards to many of
you, but sometimes you just can't find quick answers even when browsing
several books on the subjects....(of course that depends on the books you
are reading).

With Intelisense you have access to the objects lists and others, but i
can't see any indication of the "using..." statement associated with them.

An example: in order to use OpenFileDialog object I copyied code from
MVC#5 Offline Help, like this:


private void openProjectToolStripMenuItem_Click(object sender, EventArgs
e)

{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
...
{
myStream.Close();
}}


When debugging I get the following error message:

Error 1 The type or namespace name 'Stream' could not be found (are you
missing a using directive or an assembly reference?) C:\...\Form1.cs

So, what is this namespace? Is there any direct way to identify it?
To solve this I picked-up from (another) example code and add it to my
code, like this:

using System.IO;

using System.Threading;

using System.Runtime.InteropServices;

using System.Runtime.Remoting.Messaging;



Result? It works ! The point is I don't know if I was just lucky because I
picked-up the right (other) example...

Hi,

if the assembly where the class recides is already in the 'References' list
(in the solution explorer), you could place the caret between one of the
characters of the typename in your code and a small rectangle will appear
just below the last character. In your case, just below the 'm' from
'Stream'.

If you point it with your mouse, an option combo will appear where you
can select for "using ...." and it will add the using clause to your
project.

regards,
Marcel
 
A

arr uba

Hi Paul,

could suggest me a good, but concise and practical, literature (I mean,
available on the Net) on this matter?

Thanks.
 
A

arr uba

Hi Paul,

could suggest me a good, but concise and practical, literature (I mean,
available on the Net) on this matter?

Thanks.
 
P

Paul

The Apress books are quite good, or you could buy the 70-536 training Kit
for the exams which will also cover the basics but maybe at a highter level.
I have the first book and have the 2005 version of the second I can
recommend both. The Apress series probably do some intro books to .net too
but it depends on your development experience prior to .net and if you feel
comfortable jumping in to an intemediate book.

http://www.amazon.co.uk/MCTS-Self-P...=sr_1_3?ie=UTF8&s=books&qid=1243521596&sr=1-3

http://www.amazon.co.uk/Pro-2008-NE...=sr_1_9?ie=UTF8&s=books&qid=1243521596&sr=1-9
 
P

Paul

The Apress books are quite good, or you could buy the 70-536 training Kit
for the exams which will also cover the basics but maybe at a highter level.
I have the first book and have the 2005 version of the second I can
recommend both. The Apress series probably do some intro books to .net too
but it depends on your development experience prior to .net and if you feel
comfortable jumping in to an intemediate book.

http://www.amazon.co.uk/MCTS-Self-P...=sr_1_3?ie=UTF8&s=books&qid=1243521596&sr=1-3

http://www.amazon.co.uk/Pro-2008-NE...=sr_1_9?ie=UTF8&s=books&qid=1243521596&sr=1-9
 

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