using-directives

Have ReSharper keep 'using System;' when optimizing usings

Hello. I was wondering if there is some option to keep ReSharper from removing just the using System; directive? Perhaps this is configurable somewhere? Also, is there a way to have ReSharper sort the remaining directives just as Visual Studio 2008 does it (alphabetically, I think)? Thanks. ...

Organizing using directives

I've been using ReSharper for the past months and, advertising aside, I can't see myself coding without it. Since I love living on the bleeding "What the hell just went wrong" edge, I decided to try my luck w/ the latest ReSharper 4.5 nightly builds. It's all nice. However, I've noticed that the using directives grouping format has chan...

Default using directives in new C# files

Why does Visual Studio 2008 automatically insert the following using directives into each new C# file I create? using System; using System.Collections.Generic; using System.Text; What's so special about these namespaces? Are these the most frequently used ones? ...

Exposing the methods of a DLL in C#

After someone creates a DLL in C# using the Microsoft Visual development environment, how would another programmer take that code, make a new project that includes the DLL's source and make a GUI that uses the DLL'S API? I have already done the following four steps: 1) In the Solution Explorer right-click "References" and select "Add R...

Visual Studio or Resharper functionality for placement of using directives

Hi, I like to put my using directives inside the current namespace, and not outside as VS and Resharper per default puts them. Does anyone know of a macro/standard functionality that sorts/removes unused using directives and puts them inside the current namespace? --larsw ...

What's This C# "using" directive?

I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that all about? ...

Namespace references in C# vs. VB.Net

In VB.Net you can do something like the following without any issues... just ignore the fact that this is a pretty useless class :-) Imports System Public Class Class1 Public Shared Function ArrayToList(ByVal _array() As String) As Collections.Generic.List(Of String) Return New Collections.Generic.List(Of String)(_array) ...

Inheriting from classes

In C#, how many classes can you inherit from? When you write: using System.Web.UI; is that considered inheriting from a class? ...

How to prevent ReSharper from shortening namespaces when adding using directives?

When I use ReSharper to add a using directive (using Alt+Enter) it removes "unnecessary" parts of the namespace. I prefer using the full namespace which is also the behavior of Visual Studio. Example: namespace MyCompany.MyTool.Data { // This is what ReSharper gives me: using Core; // This is what I want: using MyComp...

How to avoid many using operators in every .cs file?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; I have to put the above code in almost every .cs file. Is there any way to avoid it? ...

C# using namespace directive in nested namespaces

Right, I've usually used 'using' directives as follows using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AwesomeLib { //awesome award winning class declarations making use of Linq } i've recently seen examples of such as using System; using System.Collections.Generic; using System.Lin...

missing a using directive or an assembly reference

I'm in the process of writing a small asp.net mvc application that is using the northwind.mdf. When building the solution I get this error: Error 1 The type or namespace name 'Order' could not be found (are you missing a using directive or an assembly reference?) Order is a table in the northwind database. any help is most appreciate...

Two-phase lookup: can I avoid "code bloat"?

Two-phase lookup question: Is there a more synthetic way to write this code, i.e. avoiding all those using directives? Something like using CBase<T>; is what I would like, but it is not accepted. #include <iostream> template <typename T> class CBase { protected: int a, b, c, d; // many more... public: CBase() { a = 1...

Restricting `using` directives to the current file

Sorry for this silly question, but is there any way to restrict using directives to the current file so that they don't propagate to the files that #include this file? ...

The type or namespace cannot be found (are you missing a using directive or an assembly reference?)

I get the following error when I try to compile my C# program: The type or namespace name 'Login' could not be found (are you missing a using directive or an assembly reference?) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;...

organize using directives, re-run tests?

Before making a commit, I prefer to run all hundred-something unit tests in my C# Solution, since they only take a couple minutes to run. However, if I've already run them all, all is well, and then I decide to organize the using directives in my Solution, is it really necessary to re-run the unit tests? I have a macro that goes throug...

What purpose does “using” serve when used the following way

What purpose does “using” serve when used the following way:- ONE EXAMPLE IS THIS, (AN ANSWERER- @richj - USED THIS CODE TO SOLVE A PROBLEM THANKS) private Method(SqlConnection connection) { using (SqlTransaction transaction = connection.BeginTransaction()) { try { // Use the connection here ...

Prevent Visual Studio from removing certain using directives

I frequently use the "Remove and sort usings" feature of VS/PowerCommands - in fact, with the help of R#, I make VS do this for me every time i save the document, which I almost reflexively do almost every time I finish writing a code line without errors. However, there are a couple of namespaces that, if they are there, I don't want to...

[using namespace.x] vs using [namespace.x.xx] ?

I have seen that you can either do using System.IO and use Path.GetDirectoryName(blah blah) OR directly use System.IO.Path.GetDirectoryName(blah blah); Is there any difference between them from a point of performance? Does using System.IO loads all static classes in the namespace to the memory resulting in using more memory...

Watch window stopped accepting some usings

I am using the debugger to step through my code. The code file I’m in has usings at the top, including for example using System.Linq; In Visual Studio 2008 this used to apply to the Watch window while debugging, so I could use extension methods such as .First() and .ToArray() in the watch window. For some reason, this has stopped wor...