Open gafter opened 6 years ago
using X = Y
is already valid syntax in C# that means something else entirely (it introduces a namespace or a type alias).
But it's not legal to use inside of a method scope. In fact, the compiler doesn't even consider it being a namespace/type alias when used in a method scope, so there's no ambiguity here.
using X = Y
is already valid syntax in C# that means something else entirely (it introduces a namespace or a type alias).But it's not legal to use inside of a method scope. In fact, the compiler doesn't even consider it being a namespace/type alias when used in a method scope, so there's no ambiguity here.
I'm curious as to how that would interact with the scripting form of C#, where this doesn't necessarily apply.
This is great feature, but is there anything similar planned for namespaces?
Most if not all .cs files will have this wrapping namespace in them.
namespace MyNameSpace
{
public class MyClass
{
}
}
It seems very redundant because most of the files will have single namespace just wrapping everything. It would be great to able to do this this instead
namespace MyNameSpace;
public class MyClass
{
}
@wanton7 #137.
The documentation seems to imply that this (multi-declaration implicitly typed variables) is possible:
using var f2 = new FileStream("..."), f3 = new FileStream("...");
But it doesn't look to be possible with SharpLab. Is it supposed to be possible, and wouldn't it then clash with disallowing multi-declaration var generally?
I'd file this as a bug on the documentation but the proposal says the same thing.
@JesperTreetop You can never use var with multiple declarations. You always have to specify the type explicitly.
Should #114 just mention this issue instead of both being put on the project board?
This is for some form of
using
statement, where the statements executed while the resource is held are the following statements in the same block that contains theusing
statement; the resource is freed at the end of the block.See https://github.com/dotnet/csharplang/issues/114 and https://github.com/dotnet/csharplang/issues/114#issuecomment-349773994
LDM history: