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

Using directives in new files

Is it possible to have additional "using" directives automatically added to my new aspx.cs files so that I do not have to keep typing the same ones over and over again (i.e. custom namespace using directives)
mattgcon
  • 4,768
  • 19
  • 69
  • 117
0
votes
0 answers

Angular - Do I directive or not?

Something has perplexed me about the transition of Angular. I feel that we are loading more and more functionality and logic into the html element vs the controller. It complicates things significantly and I am not sure why we do this. example:

Ezos
  • 107
  • 1
  • 12
0
votes
1 answer

Is Resharper confused by Aliases used for Assemblies in Using directives?

I noticed this in my .cs file, which looks like I might be "mixing metaphors" or at least being redundant by having both "Microsoft.Office.Interop" and "Microsoft.Office.Interop.Excel" in my list of usings directives: using…
0
votes
1 answer

Creating Directive for two views

I am trying to create a directive for two views. basically we have a modal, with header and footer. When we click on continue button in footer, the modal body should be alone changed displaying question 2 as a new view with header and footer fixed.…
nikitha
  • 179
  • 1
  • 1
  • 15
0
votes
1 answer

Angularjs directive creation

I have a set of two functions that I user to perform a lookup to identify a user. In my app I need to do this for multiple roles (i.e: requester, processor, etc.). I think I want to create a directive so that I can reuse the code without having to…
user3861284
  • 241
  • 2
  • 10
  • 22
0
votes
0 answers

Cannot bind value to attribute in angular directive

This works:

{{ctrl.StatusId}}

This doesn't

{{ctrl.StatusId}}

Underfrog
  • 1,307
  • 11
  • 14
0
votes
1 answer

Set default namespace include references for Web Form with Master template?

I would like to modify the default using statements included at the top of the code behind file of a newly created web form (with master page) in Visual Studio 2013. My application is a C# Web Application. Currently, when I use the template for "Web…
0
votes
1 answer

$compile in Directives

Hey guys i was planning out a directive i was making which would essentially be a popup with a timer on it. Basically the plan was to pass in an object which could configure the properties to construct the message. The directive would contain the…
Indrick
  • 21
  • 6
0
votes
1 answer

Angular best practice. Controller actions triggering animations

I want to show some progress circle while I'm waiting (polling) the server. I'm using some jquery circle-progress plugin for that. I want to figure out what is the most common approach to conditionally start circle progress, then at some time to…
jonasnas
  • 3,540
  • 1
  • 23
  • 32
0
votes
1 answer

How to show and hide element in my case

I am trying to create a directive modal so i can use on other place. I want the modal to pop when user do something. I use ng-show to hide it. my html my…
BonJon
  • 779
  • 1
  • 7
  • 21
0
votes
0 answers

Directives and variables

I have in my directive the controller and link in the following way: myapp.directive('MyDirective', function(){ return{ restrict: 'A', transclude: true, scope: { .... }, controller:…
user880386
  • 2,737
  • 7
  • 33
  • 41
0
votes
0 answers

Using Directives in Asp.Net MVC pages

I would like to use a use an alias in my views to make the code more expressive, so I have tried permutations of the following namespace RES.Project.MVC.ViewModels { using ECMAlertListUrl = System.String; } and in the view <%@ Page Title=""…
cedd
  • 1,741
  • 1
  • 21
  • 34
0
votes
1 answer

MVC - Should I avoid to import more namespaces in view

I know some of you guys would consider it an unrelated question but, It's an important question for an MVC developer when you making it certain to make your application efficient and speedy. As you know that we can import a namespace into a view…
Rashid Ali
  • 587
  • 3
  • 13
0
votes
5 answers

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 =…
user287745
  • 3,071
  • 10
  • 56
  • 99
0
votes
0 answers

Angularjs i cannot display my data in controller into directives

I have graphs made in Angular JS. I have two directives , the first one named Linear Chart 1 is for individual graphs and the second one named Linear Chart is compilation of each graph in the first one. My problem is that I cannot access controller…