Instance as a propertie...

  • Thread starter Thread starter Rafael Veronezi
  • Start date Start date
R

Rafael Veronezi

I saw the Indexer declaration, and was thinking, about the indexers,
properties and all those shits :-)... I thought if you can declare the class
itself as propertie....
Like:
public class Test
{
public this
{
get { return this; }
set { this = value; }
}
}

The example looks stupid...
But, since you can assign objects, I thought if it would be useful to have a
propertie declaration itself, to do some code in a case of object
assigning...
I don't know if it exists, I didn't test.... Don't know if it would be
really useful, anyways I thought that it could be possible, specially if you
had some kind static strcuture like that...

Please, I accept every penalty if I am talking bullshit hehe!
 
Rafael Veronezi said:
I saw the Indexer declaration, and was thinking, about the indexers,
properties and all those shits :-)... I thought if you can declare the class
itself as propertie....

The example looks stupid...
But, since you can assign objects, I thought if it would be useful to have a
propertie declaration itself, to do some code in a case of object
assigning...
I don't know if it exists, I didn't test.... Don't know if it would be
really useful, anyways I thought that it could be possible, specially if you
had some kind static strcuture like that...

Please, I accept every penalty if I am talking bullshit hehe!

I don't see how an instance property that returned itself could be
useful, but a static property which returns a particular instance is
useful - for instance, with Encoding.ASCII, Encoding.Unicode etc.

Similarly, virtual properties could (for instance) by *default* return
the same instance, but could return other instances if overridden.
 
Back
Top