What Language Features Do You Miss In C#?
-
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
Method-scoped variables like in VB (static). Defining Extension Methods by applying the Attribute like in VB (rather than
this
). A proper assignment operator like in Pascal:=
:-D A properdefine
directive like in C/C++# define Pi 3.14
Support forenum
inwhere
clauses for generic types --class C<T> where T : enum ...
No default modifiers (public
,private
,virtual
,sealed
, etc.). Multiple Inheritence would be good too. -
HashSet
Yes I know. We can also implement it in C++ using operator overloading. But the point is for a language future, not a pattern, collection or utility class.
There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.
-
There is
.Contains
.This one is type dependent and not a language future but some class method. Same as Split() (very useful method by the way) or IsNullOrEmpty() for example.
There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.
-
Yes I know. We can also implement it in C++ using operator overloading. But the point is for a language future, not a pattern, collection or utility class.
There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.
Yet HasSet allows other operations, such as union and intersection; would you argue for syntax to allow every such operation? I wouldn't.
-
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
What I would like to see in the language: - Destructors that destruct (not the silly Dispose() stuff) [you can easily trigger local garbage collection with an exit from scope] - Ability to use arrays with non-zero origin - inline operator||(), inline operator&&() which implement short circuit logic
-- Harvey
-
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
Multiple inheritance. Interfaces are useful as abstractions, but there are times I want to inherit concrete functionality from multiple classes. Marc
Latest Article: C# and Ruby Classes: A Deep Dive
My Blog -
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
I want lambda expressions, that can be evaluated at compile time, allowed in attributes, to avoid nasty string literals.
-
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
Having a generic type constraint on operators. Something where T : +, -, >, < Or something. Or just provide one easy way to work with numerics, for example: Something where T : numeric After which you can use +, -, >, < etc. by default and T can be int16, int 32, int64, single, byte, double, decimal or an unsigned of those.
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
-
Multiple inheritance. Interfaces are useful as abstractions, but there are times I want to inherit concrete functionality from multiple classes. Marc
Latest Article: C# and Ruby Classes: A Deep Dive
My Blog -
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
-
I would like to see the addition of a keyword to allow fallthrough in a switch statement (maybe "nobreak"?). I don't need/want to do that often, so the compiler preventing "accidental" fallthrough is nice; however, it sure would be nice to be able to fall through when necessary.
you can type several 'case' statements one after the other. contrived example:
int number = GetNumberBetween1And5();
string text = null;
switch( number ) {
case 1:
text = "1";
break;
case 2:
case 3:
case 4:
text = "2 or 3 or 4";
break;
case 5:
text = "5";
break;
}is that type of fall-through what you said you're missing?
-
A
goto case
is not agoto
. But, yes, I don't likebreak
in aswitch
; in my opinionbreak
should only be for loops only.I agree - it isn't. But...it is a out-of-structure code flow indicator, which can easily create the same spaghetti code as a goto. So on balance, while I found the no-drop-through rule limiting at first, I don't miss it so much now. I just restructure the code to not need it in the same way that I don't need goto itself. And I definitely agree on
break
- theswitch
version should have used a different word: "esac" or "join" perhaps.If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
You certainly go straight to The Heart of Everything[^]
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
Because I have A Dangerous Mind[^] :-D
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
-
In my case, actually, for every Foo<T> I also have an IFoo where the parameters are as object instead of T. I think java have such feature (I know, in java the implementation is completely different)... I think they use: Foo<?> to say that they don't know the type being used. It is slower than having it rightly typed, but it is faster than having it as dynamic or through reflection.
why the heck you just don't use a generic method?
public void DoGenericStuff(Foo foo)
{
....
}I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241
-
Method-scoped variables like in VB (static). Defining Extension Methods by applying the Attribute like in VB (rather than
this
). A proper assignment operator like in Pascal:=
:-D A properdefine
directive like in C/C++# define Pi 3.14
Support forenum
inwhere
clauses for generic types --class C<T> where T : enum ...
No default modifiers (public
,private
,virtual
,sealed
, etc.). Multiple Inheritence would be good too.PIEBALDconsult wrote:
A proper assignment operator like in Pascal
:=
:-D
A properdefine
directive like in C/C++# define Pi 3.14
... Multiple Inheritence would be good too.if any of thouse got added i would be sooo mad, i alread have too much bad code to deal even without those...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241
-
What I would like to see in the language: - Destructors that destruct (not the silly Dispose() stuff) [you can easily trigger local garbage collection with an exit from scope] - Ability to use arrays with non-zero origin - inline operator||(), inline operator&&() which implement short circuit logic
-- Harvey
H.Brydon wrote:
Destructors that destruct (not the silly Dispose() stuff) [you can easily trigger local garbage collection with an exit from scope]
I couldn't agree more.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241
-
I want lambda expressions, that can be evaluated at compile time, allowed in attributes, to avoid nasty string literals.
that's not allowed with an Expression parameter?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p) "Given the chance I'd rather work smart than work hard." - PHS241
-
Plugin support is always an issue with C#. You can't use User Controls inside a Console Application, which makes that coding needs to be done each class. C++ holds great support for adding plugins for extra code (.h files sepcifically are useful) but in the end, you can't blame Microsoft for their .NET approach to everything, The time of a CLI is dead (Except PowerShell, IMO)