P
Picho
Hi everyone.
Is it possible to decalre a static indexer to a class?
obviosly not, because the 'this' keyword is not valid when declaring it
static...
so how can I get a similar result of an indexer WITHOUT using accessor
methods like
static object GetObject(int index){...}
and
static void SetObject(int index, object value){...}
?
another question:
lets say i have a class:
public class ClassA
{
private object _value;
public ClassA()
{
}
public object Value
{
get{...}
set{...}
}
}
Can I cause one of the class properties to be a ... lets say default
property?
so I can write something like:
ClassA c = new ClassA();
c = null;
//instead of:
c.Value = null;
I know this looks twisted and silly, but i would realy like to try this -
skipping the property access stage (the property type is an object and thats
a given).
I tried creating an implicit conversion to and from 'object' which looked
like the right direction to me but then I got a compiler error that says I
cant cast from a base class (since ClassA derives from object naturally..)
smart compiler. silly me.
anyways,
can I do this in some manner or is it hopeless?
thanx alot,
Picho
Is it possible to decalre a static indexer to a class?
obviosly not, because the 'this' keyword is not valid when declaring it
static...
so how can I get a similar result of an indexer WITHOUT using accessor
methods like
static object GetObject(int index){...}
and
static void SetObject(int index, object value){...}
?
another question:
lets say i have a class:
public class ClassA
{
private object _value;
public ClassA()
{
}
public object Value
{
get{...}
set{...}
}
}
Can I cause one of the class properties to be a ... lets say default
property?
so I can write something like:
ClassA c = new ClassA();
c = null;
//instead of:
c.Value = null;
I know this looks twisted and silly, but i would realy like to try this -
skipping the property access stage (the property type is an object and thats
a given).
I tried creating an implicit conversion to and from 'object' which looked
like the right direction to me but then I got a compiler error that says I
cant cast from a base class (since ClassA derives from object naturally..)
smart compiler. silly me.
anyways,
can I do this in some manner or is it hopeless?
thanx alot,
Picho