P
Phoenix
A couple of suggestions for enhancing the .Net CLR:
Property indexers:
To be able to have an indexed property (as opposed to a
type's indexer) without having to create a subtype.
Example:
class MyClass
{
public int MyIndexedProperty[int index]
{
get{...}
set{...}
}
}
....
MyClass o = new MyClass();
o.MyIndexedProperty = foo;
This would reduce coding by reducing the number of
auxiliary types that need to be defined to do the same
thing today.
---------------------------------------------------------
Static indexers:
Useful when a type has a list of possible instances,
rather than a named set.
Example:
public struct MyStruct
{
static MyStruct[] myStructs;
public static this[int index]
{
get{return mystructs[index];}
}
}
....
MyStruct o = MyStruct
The same can be accomplished thru a typical static
property, but this notation seems a bit cleaner.
------------------------------------------------------
Different accessibility on property gets and sets:
A favorite technique of mine in my VB6 days; still
lamenting its loss in the CLR. VB6 allowed us to have a
property that had
a public get accessor, and a friend set accessor, like so:
Public Property Get MyProperty As Long
Friend Property Let MyProperty(lValue As Long)
This used to be great; the project's internal code could
use the same property name to set a property that the
public interface exposed for gets. Now, we have to define
2 properties with 2 different names to get the same effect:
public int MyProperty
{
get{return myProperty;}
}
internal int MyProperty_Internal
{
set{myProperty = value;}
}
Example of what I'd really like to code for this:
public int MyProperty
{
get {return myProperty;}
internal set {myProperty = value;}
}
Even if it were just a compiler trick, this ability would
be awesome to have back.
Property indexers:
To be able to have an indexed property (as opposed to a
type's indexer) without having to create a subtype.
Example:
class MyClass
{
public int MyIndexedProperty[int index]
{
get{...}
set{...}
}
}
....
MyClass o = new MyClass();
o.MyIndexedProperty = foo;
This would reduce coding by reducing the number of
auxiliary types that need to be defined to do the same
thing today.
---------------------------------------------------------
Static indexers:
Useful when a type has a list of possible instances,
rather than a named set.
Example:
public struct MyStruct
{
static MyStruct[] myStructs;
public static this[int index]
{
get{return mystructs[index];}
}
}
....
MyStruct o = MyStruct
The same can be accomplished thru a typical static
property, but this notation seems a bit cleaner.
------------------------------------------------------
Different accessibility on property gets and sets:
A favorite technique of mine in my VB6 days; still
lamenting its loss in the CLR. VB6 allowed us to have a
property that had
a public get accessor, and a friend set accessor, like so:
Public Property Get MyProperty As Long
Friend Property Let MyProperty(lValue As Long)
This used to be great; the project's internal code could
use the same property name to set a property that the
public interface exposed for gets. Now, we have to define
2 properties with 2 different names to get the same effect:
public int MyProperty
{
get{return myProperty;}
}
internal int MyProperty_Internal
{
set{myProperty = value;}
}
Example of what I'd really like to code for this:
public int MyProperty
{
get {return myProperty;}
internal set {myProperty = value;}
}
Even if it were just a compiler trick, this ability would
be awesome to have back.