Questions tagged [using-directives]

The `using` directive, available in several languages including C# and C++, introduces members of a namespace into the current identifier search scope.

The C++ using directive allows the names in a namespace to be used without the namespace-name as an explicit qualifier. Of course, the complete, qualified name can still be used to improve readability.

// C++ Example:
using std::cout

The C# using directive is used to qualify namespaces and create namespace or type aliases. The scope of a using directive is limited to the file in which it appears.

// C# Example:
using System.Text;
using Project = PC.MyCompany.Project;

Creating an alias for a namespace or a type in C# is called a "using alias directive", and is illustrated in the code sample below:

namespace PC
{
    // Define an alias for the nested namespace. 
    using Project = PC.MyCompany.Project;
    class A
    {
        void M()
        {
            // Use the alias
            Project.MyClass mc = new Project.MyClass();
        }
    }
    namespace MyCompany
    {
        namespace Project
        {
            public class MyClass { }
        }
    }
}
289 questions
0
votes
2 answers

The directive is not detected from another file C#, .Net

I have a config file that contains all the configurations of my program. In that file, I define a directive as follow: ---------- MyConfig.cs ------------ #define TEST_LOCALHOST public class MyConfig { .... } Now, from another file…
chipbk10
  • 5,783
  • 12
  • 49
  • 85
0
votes
2 answers

"The type or namespace 'name' is missing" when it is included in references and using directives

I have a very weird problem. I am developing a Sharepoint 2013 Project which consists of a WebPart and a couple of Lists. I am using a DateTimeControl in the WebPart. I moved the WebPart into another project yesterday. After I moved it, I got an…
LeonidasFett
  • 3,052
  • 4
  • 46
  • 76
0
votes
1 answer

How to introduce a static method of a class to a namespace?

For example, I have a class A and a static method foo for the class. I have a namespace nm and want to introduce A::foo to the namespace. I try the following namespace nm { using A::foo; void f() { foo(...); // use A::foo …
user1899020
  • 13,167
  • 21
  • 79
  • 154
0
votes
1 answer

Is there a better way to manage using namespace directives in the head of a file

I'm a complete newb. I see that these using statements or references at the top of the page are a pain to manage. Is there a way to reference these in a class or some other file and have a single statement at the top of the form code or in a logic…
Frank Pytel
  • 127
  • 16
0
votes
1 answer

what is using SR=MS.Internal.PresentationCore.SR?

I'm going through some ms source code and ran into the two using directives: sing SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; Can't find anything using with Google or Bing. My first guess is that they are…
0
votes
0 answers

Changing Preprocessor Directives C++

So I am trying to use a really old library (last updated in 1999) that performs numerical integration over two-dimensional regions using cubature rules. The problem I'm encountering is that every single file in the library (both headers and source…
Mr. Frobenius
  • 324
  • 2
  • 8
0
votes
1 answer

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…
0
votes
1 answer

missing directive or assembly reference?

I am trying to recompile an application but I am getting this error: Error 10 The type or namespace name 'SettingItem' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and…
0
votes
4 answers

Using Directive C++ Implementation

In C, if I use #include "someFile.h", the preprocessor does a textual import, meaning that the contents of someFile.h are "copy and pasted" onto the #include line. In C++, there is the using directive. Does this work in a similar way to the…
Brian Tracy
  • 6,801
  • 2
  • 33
  • 48
0
votes
0 answers

AngularJS: Reusable directive and isolated scope: accessing the model in HTML

Isolated scopes has been discussed a lot, but I couldn't find a similar case. I am using Angular in a website where the views are generated in PHP. I have this kind of example of HTML content:
Laurent
  • 977
  • 3
  • 13
  • 27
0
votes
0 answers

How to call a function from a directive on ng-click with AngularJS?

I've a directive that gets data from 2 separate $http calls and populates 2 different ng-repeat. In order to reduce the server calls, I'm looking into making the second call only upon ng-click of a certain element of the first ng-repeat list. So,…
Eric Mitjans
  • 2,149
  • 5
  • 40
  • 69
0
votes
2 answers

System.Windows.Forms.Timer does not exist

I am trying to set up a timer in c#. In "using" part I have included this using System.Windows.Forms.Timer; My timer looks like this: private Timer timer1; public void InitTimer() { timer1 = new Timer(); timer1.Tick += new…
user2886091
  • 725
  • 7
  • 16
  • 29
0
votes
1 answer

Bypassing inclusion of different directives faster or negligible?

Does bypassing the use of a directive make any real difference in the execution of an application? Obviously my below example isn't going to really matter as it is so small, but if this application were on a much, MUCH larger scale, would it make a…
Volearix
  • 1,573
  • 3
  • 23
  • 49
0
votes
1 answer

Problems with a reusable Click to Edit Directive on AngularJS

I'm using the Reusable Click to Edit Directive from Icelab. I've used it successfully in several places in my app, but I run into problems when I try to edit elements that are inside other directives. As the directives are calling the elements one…
Eric Mitjans
  • 2,149
  • 5
  • 40
  • 69
0
votes
1 answer

Showing multiple tooltips at one time in angularJS

How can I disable all other tooltips except the one on which my mouse is over? What I am trying to acchieve is excluding tooltips from showing up except the one which has showed up as the last one. Sometimes too much toolips show up making it…
Pille
  • 1,123
  • 4
  • 16
  • 38