c# - Initialize base class in .NET -


How do I need to initialize an object's base with the current object? For example, in this scenario:

  public class A {public string field 1; Public string field 2; } Public Sector B: A {Public String Field 3; Assigned public zeros (one source) {this.base = source; // & lt; - Will not work, what can I do here? }}  

Assign () method, can clearly specify the value for the Base Class field-by-field, but there is no better solution? Since the class emits from BA, there should be a way of assigning A. just for B

In C ++ there will be a small thing to do this, but I do not seem to understand that How to do it is read maliciously base .

[edit] Well, this is probably not unfortunate between the base class and a class class Relationship IS-A is not HAS-A . You can change your reference to the child class by allowing the child class to change the example of the base class, because it is the IS-A base class if you really need this methodology then I suggest you I want to replace your succession model which you really want to do. String field 1; Public string field 2; } Public class B {public string field 3; Public AA; Assigned public zeros (one source) {this.a = source; }}

seems more appropriate and has a clear meaning and functionality.


Comments