c# - How to downcast this to the base class? -


i have class hierarchy:

public abstract class aclass : someframeworkclass {   [workonthisproperty(with.some.context)]   private myobject myproperty { get; set; }      public override void onsomethinghappened() {     externalframework.workon(this);   } }  public class bclass : aclass {   // ... snip ... } 

externalframework operating on this: instance of bclass need operate on this instance of aclass because externalframework works on type of object passed in , not go inheritance hierarchy. how can downcast this aclass externalframework can detect myproperty?

i've tried casting this object , aclass, , casting directly aclass cast unnecessary doesn't seem run. can this?

edit: externalframework cheeseknife. trying inject couple views base fragment class has reusable logic while child fragment classes implement specific behaviour tuning.

the problem private members of class can accessed inside of same class.

with code:

class { private string property { get; set; } } class b : { public string proxy => property; } 

we'll compilation error because class b cannot access private property class a, if change keyword protected :

class { protected string property { get; set; } }

it should work.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -