batista,
You will have to make sure that the original class declares GetVariable
as virtual, so that it can be overridden by derived classes. If it is not,
then there is little you could do (you could shadow it with the new keyword,
but that is evil).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"batista" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello to ALL,
>
> I'll explain my problem by pseudo code
>
> class A
> {
> int x;
> char y;
> string z;
> }
>
> class B
> {
> GetVariable(int i)
> {
> A a = new A();
> //Now I want to return the ith varaible
> //of class A
> }
> }
>
> class C
> {
> GetVar()
> {
> B b = new B();
> b.GetVariable(0) //it shud return x
> b.GetVariable(1) //it shud return y
> b.GetVariable(2) //it shud return z
> }
> }
>
> Now how do I implement the GetVariable(int i), in C#
> The reason I have class B is because there are lot's of classes
> like class A, and i don't want to edit them all.
>
> Any Suggestions...
>
> Thanks In advance...
> Cheers...
>
> Bye
>