Note that there are some explanatory texts on larger screens.

plurals
  1. POC# call derived class property using base class reference
    primarykey
    data
    text
    <p>I have a class <code>RequestDetail</code>. There are 2 classes classA and classB derived from it such that each of them has their own property:</p> <pre><code>public partial classA : RequestDetail { ..... } public partial classB : RequestDetail { ..... } </code></pre> <p>I am writing a method <code>CreateMethod1(ClassA a)</code> and <code>CreateMethod2(ClassB b)</code>.</p> <p>Both methods doing the same stuff except some minor difference. I would like to write a generic method and call that method by passing the reference in CreateMethod1 and CreateMethod2.</p> <p>Can anyone help me in doing this?</p> <p>THanks</p> <h2>EDIT:</h2> <p>What I have excluded is I have received a WSDL which when generated gives me four separate classes that inherit from a base class with around 20 properties. They only differ very slightly, to be exact 2 classes contain the same field (IsUrgent), the third contains (Ticket and Reason) and the fourth contains (BudgetCode) The persistance however is exactly the same for all implementations. I dont want to create 4 seperate methods to persist the same information.</p> <p>Its worth noting the classes are <strong>partial.</strong></p> <p><strong>xsd</strong> looks like following</p> <pre><code>&lt;xs:complexType name="ClassA"&gt; &lt;xs:complexContent&gt; &lt;xs:extension base="IARequestDetails"&gt; &lt;xs:sequence&gt; &lt;xs:element name="IsUrgent" type="IAUrgency"/&gt; &lt;/xs:sequence&gt; &lt;/xs:extension&gt; &lt;/xs:complexContent&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="ClassB"&gt; &lt;xs:complexContent&gt; &lt;xs:extension base="IARequestDetails"&gt; &lt;xs:sequence&gt; &lt;xs:element name="BudgetCode" type="ProjectBudgetCode"/&gt; &lt;xs:element name="IsUrgent" type="IAUrgency"/&gt; &lt;/xs:sequence&gt; &lt;/xs:extension&gt; &lt;/xs:complexContent&gt; &lt;/xs:complexType&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload