3 ms·
In C# I'd like to able to : - declare a namespace for the file (no indentation) - declare that the file is a class and can only contain one (top level) class
by jrimbault 6y ago
In C# I'd like to able to :
- declare a namespace for the file (no indentation)
- declare that the file is a class and can only contain one (top level) class (still no indentation)
- `using` statements that don't import every symbol into my namespace :
using System.Console;
...
Console.WriteLine();
instead of :
using Sytem;
...
Console.WriteLine(); // where does "Console" come from ? god/IDE only knows
But yes, no to top-level programs.
But alreay with these few changes, I've saved 10% of the 80 columns width. I've made it easy to read a file without an IDE. You can start to write actual code at indentation level 0. I've made it easy to have one class per file and hard to have two class per file, in the spirit of making good pratice easy and bad practice hard.
- daeken 6y agoTotally agreed on all these, though I've personally gotten around the last one by making use of `using static System.Console;` -- then you can just do `WriteLine(...);` It doesn't solve the fundamental issue, but it definitely makes things clearer for me.
- Mindless2112 6y agoYou can do using Console = System.Console;
- jrimbault 6y agoThe point is : the C# namespaces, default behaviors and general usage, are only half of a good idea. Effectively importing every symbol in a namespace into the local namespace by default is so obviously bad. Yes you can do `using Whatever = System.Console;`, fantastic, that's not the common idiom and it is harder to do (longer to write) than the usual idiom.
- kqr 6y agoIsn't this basically stuff F# nearly defaults too?