using-directives

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

∥☆過路亽.° 提交于 2019-12-17 16:55:11
问题 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; using System.Windows.Forms; namespace FootballLeague { public partial class MainMenu : Form { FootballLeagueDatabase footballLeagueDatabase; Game game; Team team;

Scoped using-directive within a struct/class declaration? [duplicate]

喜夏-厌秋 提交于 2019-12-17 10:39:07
问题 This question already has answers here : Why “using namespace X;” is not allowed inside class/struct level? (3 answers) Closed 2 years ago . I find that my C++ header files are quite hard to read (and really tedious to type) with all the fully-qualified types (which goes as deep as 4 nested namespaces). This is the question (all the answers give messy alternatives to implementing it, but that's not the question): Is there a strong reason against introducing scoped using-directive in structs

what should i do for working with closedxml correctly in asp.net [duplicate]

送分小仙女□ 提交于 2019-12-13 10:06:20
问题 This question already has answers here : The type or namespace cannot be found (are you missing a using directive or an assembly reference?) (5 answers) Closed 4 years ago . I'm using gridview on my webform and I want to export data from SQL server to excel using asp.net c#, and I'm using ClosedXML.Excel but the error is The type or namespace name 'ClosedXML' could not be found (are you missing a using directive or an assembly reference?) How could I remove this? 回答1: It because you have not

How to use an alias type as a generic type parameter in C# [duplicate]

给你一囗甜甜゛ 提交于 2019-12-13 02:59:17
问题 This question already has answers here : Why can one aliased C# Type not be accessed by another? (3 answers) Closed 2 years ago . How do you pass an alias type defined by using to the generic class? I tried the following code: using ID = Int32; // it might be replaced with `String`. using CC = C<ID>; public class C<T> { T id; } and there will be an error: Error CS0246 The type or namespace name 'ID' could not be found (are you missing a using directive or an assembly reference?) But the using

Forward declarations cause errors after code refactor

北战南征 提交于 2019-12-12 11:14:50
问题 My original class structure was similar to: //def.h namespace A { struct X {}; } and forward declarations where needed: //file that needs forward declarations namespace A { struct X; } After some refactoring, X was moved to a different namespace, but to keep old code "working" using directives were used: //def.h namespace B { struct X {}; } namespace A { using ::B::X; } Now we can access the same class keeping the old syntax A::X , but the forward declarations cause errors. The second problem

Visual Studio C# does not allow me to use Microsoft.AspNet.Identity namespace

徘徊边缘 提交于 2019-12-12 03:46:25
问题 Why is my application not letting me use the following namespace: using Microsoft.AspNet.Identity; Is there any way I can get rid of this in Visual Studio 2015 ? 回答1: While the other answers here are correct in explaining how to fix this issue, they don't really understand what you're doing or why it's necessary. The libraries that get referenced by default do not include types in the Microsoft.AspNet.Identity namespace. So you need to reference an assembly that contains that in order to

Example of error caused by using directive in namespaces

帅比萌擦擦* 提交于 2019-12-11 06:54:24
问题 I'm trying to understand what kind of errors could arise from including using declarations in namespaces. I'm taking into account these links. I'm trying to create an example where an error is being caused by a name being silently replaced by an header file being loaded before another one, due to usage of the using declaration. Here I'm defining MyProject::vector : // base.h #ifndef BASE_H #define BASE_H namespace MyProject { class vector {}; } #endif This is the "bad" header: here I'm trying

Why is “using namespace std;” considered bad practice?

可紊 提交于 2019-12-10 10:40:17
问题 I've been told by others that writing using namespace std; in code is wrong, and that I should use std::cout and std::cin directly instead. Why is using namespace std; considered a bad practice? Is it inefficient or does it risk declaring ambiguous variables (variables that share the same name as a function in std namespace)? Does it impact performance? 回答1: This is not related to performance at all. But consider this: you are using two libraries called Foo and Bar: using namespace foo; using

C# using namespace directive in nested namespaces

别来无恙 提交于 2019-12-10 10:18:51
问题 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.Linq; using System.Text; namespace AwesomeLib { //awesome award winning class declarations making use of Linq namespace DataLibrary { using System.Data; //Data access

Why can't I write IO.Directory.GetFiles?

 ̄綄美尐妖づ 提交于 2019-12-08 19:08:22
问题 I come from a VB.Net environment, where using Imports System and then IO.Directory.GetFiles(...) works. On the other hand, it seems that using System; is not sufficient to write use IO.Directory without prefixing it with System. . The only workaround seems to be using IO = System.IO; Why? Example code: using System; using System.IO; namespace Test { class Program { static void Main(string[] args) { System.Console.WriteLine(IO.Directory.GetFiles(System.Environment.CurrentDirectory)[0]); } } }