471,604 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,604 software developers and data experts.

Placement of Using

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
{
Nov 17 '05 #1
3 2033
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

Mike L wrote:
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
{

Nov 17 '05 #2
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

"Mike L" <Ca***@nospam.nospam> wrote in message
news:57**********************************@microsof t.com...
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
{

Nov 17 '05 #3
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

"Mike L" <Ca***@nospam.nospam> wrote in message
news:57**********************************@microsof t.com...
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
{

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by Giancarlo Niccolai | last post: by
20 posts views Thread by Ioannis Vranos | last post: by
8 posts views Thread by elviin | last post: by
6 posts views Thread by Marc Mutz | last post: by
3 posts views Thread by Brian Gideon | last post: by
1 post views Thread by SarahT | last post: by
5 posts views Thread by Lagarde Sébastien | last post: by
15 posts views Thread by LuB | last post: by
9 posts views Thread by karthikbalaguru | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.