Placement of Using

G

Guest

Should the command call "using" be before or after my namespace?

**AFTER**

namespace DataGridBrowser
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;


**BEFORE**

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace DataGridBrowser
{
 
F

Frank Rizzo

At the risk of starting a religious war, my feeling is that it should be
before the name space. There is another very good developer sitting
right next to me and he places the using statements inside the namespace.

If you consider the ReSharper product somewhat an authority of source
code formatting, they my way is correct.
If you tell it to get rid of redundant using statements, it will move
all of them out of the namespace.

Regards
 
R

Raj Chudasama

Haha good question

I always put before. Most examples I have see also put them before. But I
have ran across one or two examples where they put them after.

raj
 
J

James Curran

First of all, it's the "directive" called "using".

When placed outside of the namespace, it is in effect for the entire
file. When placed inside the namespace, it is in effect just for the scope
of that namespace. Since 99.9% of the time, you will have only one
namespace inside a file, it makes little difference.

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
 

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

Similar Threads

Using statements inside namespace 5
Strange String Sorting 2
Screen Color 12
getting rid of the carot 10
Pass values b/w forms using properties 4
Form1.Visible= false C# 3
OpenFileDialog in web forms 1
Print question 14

Top