Experiment on forced conversion between parent class and subclass in C #

Source: Internet
Author: User

In order to save time for more friends who are still learning, just like me, here is an ugly show. If you are a master, please provide guidance and do not combat the enthusiasm of cainiao.
 

The Code contains detailed annotations, so the code is directly written.


Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml. Linq;

Namespace WebApplication3
{

/// <Summary>
/// Class a intentionally defines two fields
/// </Summary>
Public class
{
Public string itema1 {get; set ;}
Public string itema2 {get; set ;}
Public string PrintItem ()
{
Return itema1 + itema2;
}
}
/// <Summary>
/// Class B intentionally defines one field, plus three fields inherited from Class.
/// </Summary>
Public class B:
{
Public string itemb1 {get; set ;}


Public string PrintItemb ()
{
Return itema1 + itema2 + itemb1;
}
}


Public partial class WebForm1: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
// Next, let's test and instantiate Class a and Class B and assign them to different values.
A aa =

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.