Beginners Guide ebook question

In reading the ebook, on page 17 section “7.5 What Assemblies to Add?”
it says for now to add the following assemblies.

GHIElectronics.NETMF.Hardware
GHIElectronics.NETMF.IO
GHIElectronics.NETMF.System
Microsoft.SPOT.Hardware
Microsoft.SPOT.Native
Microsoft.SPOT.Hardware.SerialPort
Microsoft.SPOT.IO
mscorlib
System
System.IO

If i add them they why do i also have to add things like “using” in my application ?
I.E. using GHIElectronics.NETMF.FEZ;

It is not clear to me why i am telling it to add these assemblies but also have to say “using…”

would someone please elaborate.

You don’t HAVE to use Using, but, it makes your code a lot easier if you do. The Using directive allows you to reference objects of a specific type in your code file without having to write out the entire namespace for each object. For Example, if I want to reference the Fez_Pin type in code, I could write out:

GHIElectronics.NETMF.FEZ.Fez_Pin etc every time, OR, I could add

using GHIElectronics.NETMF.FEZ; to the top of my page, and then simply type Fez_Pin anywhere in that code when I want to reference that assembly. Does that make sense?

That is what i first thought, but when i commented out the

“using Microsoft.SPOT.Hardware.SerialPort”

then the compiler complained about this line of code,
SerialPort UART = new SerialPort(“COM1”, 115200);

Even though i had it in my references.

You are required to add using for the file that needs the assemblies you have in your project.

You may have 100 files but only one is “using” the assembly

ok, thanks for the clarification.

The using isn’t required but it does make life easier. For your code to work w/o a using statement, you would have to write it as:

Microsoft.SPOT.Hardware.SerialPort UART = new Microsoft.SPOT.Hardware.SerialPort(“COM1”, 115200);

or an even better syntax would be…

var UART = new Microsoft.SPOT.Hardware.SerialPort(“COM1”, 115200);

Thanks, I have just so much to learn it is becoming overwhelming.

var UART = new Microsoft.SPOT.Hardware.SerialPort("COM1", 115200);

The ONLY time I use var is when using LINQ :wink:

Some people just love to type. Your finger muscles thank you :wink: