Home > Archive > C# > February 2005 > Any way to add "new" operators?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Any way to add "new" operators?
|
|
| Joel Thornton 2005-02-12, 3:57 pm |
| I'm pretty sure the answer is "no" but thought I'd ask anyway: is there
a way to create new operators in C#? In other words define a new custom
syntactical operator then overload it.
If you're curious, I would like to add an array range operator that
works like this:
string[] fullArray = { 1, 2, 3, 4, 5, 6 };
string[] subArray = fullArray[2..4]; // == { 3, 4, 5 }
Thanks!
Joel
| |
| Keenan Newton 2005-02-13, 8:59 am |
| Best to my knowledge you can not and I don=E8t think it is a good idea
even if you could. However, you got to remember the real power of .Net
is not the langauge but the CLR. May this feature benefit other
languages? Does this have to be a language specific feature?
With this in mind why don=E8t you create a class with possible a static
method that can do this for you. MyFunctions.BuildRangedArray(2, 4);
The best part about this is that this feature can be shared between any
..Net language.
|
|
|
|
|