About class inheritance in Asp.net

Source: Internet
Author: User

1. Whether the compilation method copies the CSC and system files to the Web. After compilation
Delete them and call them on the ASPX page.

After writing a. BAT file, you also need to copy it to compile it successfully!

How did you compile it?

2. Why is my extendedprofile unable to construct its own function? It inherits the attributes of the profile.
In the test, we found that the profile function can be used, but its own function is actually effective, prompting
An object reference is required for the nonstatic field, method,
Or property 'heritance. extendedprofile. getaddress ()

3 profile. CS
Namespace inheritance
{
Using system;
Using system. text;
Public class Profile
{
Private string _ firstname;
Private string _ lastname;
Private string _ phonenumber;

Public Profile ()
{
_ Firstname = "yang ";
_ Lastname = "sy ";
_ Phonenumber = "1357382776 ";

}
Public void setphonenumber (string phonenumber)
{
_ Phonenumber = phonenumber;
}
Public String getphonenumber ()
{
Return _ phonenumber;
}
Public void setfirstname (string firstname)
{
_ Firstname = firstname;
}
Public String getfirstname ()
{
Return _ firstname;
}
Public void setlastname (string lastname)
{
_ Lastname = lastname;
}
Public String getlastname ()
{
Return _ lastname;
}
}

Public class extendedprofile: Profile
{
Private string _ address;
Private string _ city;
Private string _ state;

Public extendedprofile ()
{
_ Address = "Room G, 16/F, light ride building, No. 88 Xiangjiang Road, Qingdao Economic and Technological Development Zone ";
_ City = "Qingdao ";
_ State = "Shandong ";

}
Public void setaddress (string address)
{
_ Address = address;
}
Public String getaddress ()
{
Return _ address;
}
Public void setcity (string City)
{
_ City = city;
}
Public String getcity ()
{
Return _ city;
}
Public void setstate (string state)
{
_ State = State;
}
Public String getstate ()
{
Return _ state;
}
}
}

4 call extendedprofile
message. innerhtml + = "Address:" + extendedprofile. getaddress () + "
";
message. innerhtml + = "City:" + extendedprofile. getcity () + "
";
message. innerhtml + = "state:" + extendedprofile. getstate () + "
";

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.