oop - C# Get subclass attribute value -


i'm trying make this:

class {     //attibutes }  class b : {    public int classbattribute = 5;    // other attributes , methods } 

my question if have instance of class how can instance of b class or access attributes?

b b = new b(); application.add(b);  //other form a = application.geta(); b b = getbfroma(a);// ???  note:  b b = b; does't work tried 

you cannot -- there no magical way create derived objects base objects in general.

to enable such scheme class b need define constructor accepts a argument:

public b(a a) {     // whatever makes sense create b } 

which can use as

var b = new b(a); 

of course after a , b different objects; changing 1 not affect other.

you should terminology right in order avoid confusion: classbattribute not attribute, field.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -