using Questions
1
The following code compiles with g++ 14.2 and clang++ 18.1, but fails with MSVC 17.10.
class Base {
public:
using peak = Base;
Base() = default;
};
class Derived : public Base {
protected:
usin...
Outland asked 14/9, 2024 at 13:49
3
If the base class depends on the template parameter, its scope is not examined in the unqualified name lookup. I can use the using declaration to introduce names from the base class. Suppose now I ...
11
I need to force the use of "using" to dispose a new instance of a class.
public class MyClass : IDisposable
{
...
}
using(MyClass obj = new MyClass()) // Force to use "using"
{
}
Dikdik asked 20/4, 2010 at 13:38
6
Solved
Is it safe to use the using statement on a (potentially) null object?
Consider the following example:
class Test {
IDisposable GetObject(string name) {
// returns null if not found
}
void DoS...
Centrosymmetric asked 26/3, 2010 at 11:22
7
Solved
In a MySQL JOIN, what is the difference between ON and USING()? As far as I can tell, USING() is just more convenient syntax, whereas ON allows a little more flexibility when the column names are n...
4
Solved
public class Abbreviation
{
public string ShortName { get; set; }
public string LongName { get; set; }
}
I have a list of Abbreviation objects like this:
List abbreviations = new List();
abb...
2
In a situation when some struct D inherits another struct A twice: once privately via B and the second time publicly via C, is it allowed to write using B::A in D?
struct A {};
class B : A {};
stru...
Guanase asked 24/9, 2021 at 7:24
7
Solved
With using namespace I make the whole contents of that namespace directly visible without using the namespace qualifier. This can cause problems if using namespace occurs in widely used headers - w...
Nonesuch asked 28/1, 2010 at 7:23
1
This question comes up a lot, is there any way to get Microsoft's attention and convince them to stop inserting this extremely annoying feature?
If I have a C# file that doesn't currently use Syste...
Turk asked 10/3, 2023 at 15:52
3
Solved
In C++, it's easy to write something along the lines of:
#ifdef FAST
typedef Real float;
#endif
#ifdef SLOW
typedef Real double;
#endif
#ifdef SLOWER
typedef Real quad;
#endif
In some common h...
8
Solved
First question:
Say I have
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string storedProc = "GetData";
SqlCommand command = new SqlCommand(store...
Nostomania asked 17/1, 2011 at 20:55
3
Solved
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/using#using-declaration
The lifetime of a using local will extend to the end of the scope in which it is dec...
Adi asked 5/1, 2023 at 0:54
3
Solved
Let's say I have a method foo which returns a ValueTuple where one of it's members is disposable, for example (IDisposable, int).
What is the best way to make sure the returned disposable object i...
Coccidiosis asked 26/9, 2017 at 12:21
2
Solved
I have a function in my code which only accepts a class member method as a template parameter. I need to call this method using a class method which is inherited from a parent class. Here is an exa...
Javed asked 4/5, 2022 at 11:10
1
In the following program, struct B has two user-defined constructors: one from int and another from int&& (clearly this is not very practical). And an object of B is created from an l-value...
Pester asked 6/2, 2022 at 8:47
4
Solved
I have installed costura.fody into my project using nuget package. I have updated the FodyWeavers.xml file with:
<Costura
Unmanaged32Assemblies='dllname'
Unmanaged64Assemblies='dllname' />
...
Chock asked 13/11, 2015 at 15:6
1
I compiled the code below using g++ 6.3.0, with -std=c++14 option.
#include <utility>
#include <iostream>
struct A{
int x;
A(const A&)=default;
A(int x):x(x){}
};
struct B{
A ...
Arista asked 15/9, 2017 at 18:29
6
Solved
class C {
using namespace std; // error
};
namespace N {
using namespace std; // ok
}
int main () {
using namespace std; // ok
}
I want to know the motivation behind it.
Decaliter asked 13/6, 2011 at 4:56
1
In a code like this
using (var sftp = new SftpClient(_host, _userName, _password))
{
sftp.Connect();
// Do some work with sftp
sftp.Disconnect();
}
Is sftp.Disconnect() call necessary or will...
Mediacy asked 6/1, 2017 at 17:42
6
I'm trying to define a pair of type aliases at the top of my C# program. This is a short example of what I'm trying to do:
using System;
using System.Collections.Generic;
namespace Foo {
using T...
3
Solved
I was trying to learn and adopt the copy-swap idiom following this thorough explanation on this question: the Copy-Swap Idiom.
But I found some code I had never seen: using std::swap; // all...
Buxtehude asked 24/1, 2011 at 13:44
3
Solved
System.Windows.Markup.XamlParseExceptionoccurred
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'Set pro...
Hessler asked 22/4, 2014 at 11:35
5
Solved
I wrote the below code in order to explain my issue. If I comment the line 11 (with the keyword "using"), the compiler does not compile the file and displays this error: invalid conversion from 'ch...
Whizbang asked 13/12, 2009 at 15:32
2
Solved
5
How can I use a variable outside the using statement ?
I have this code:
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["batch"].ConnectionString))
{
...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.