关于在asp.net中类的继承问题
1 编译的方法是否是把csc与system等的相关文件拷贝到web下,进行编译之后
然后删除他们,然后在aspx页面中调用。
写了一个.bat的处理文件,也需要拷贝之后,才可以成功编译!
请问大家是怎么编译的?
2 为什么我的extendedprofile不能构造自己的函数,它是继承了profile的属性。
在测试中发现可以使用profile的函数,但它自己的函数却实效,提示
An object reference is required for the nonstatic field, method,
or property 'inheritance.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="青岛经济技术开发区香江路88号轻骑大厦16楼G室";
_City="青岛";
_State="山东";
}
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 调用extendedprofile
Message.InnerHtml+="Address:"+ExtendedProfile.getAddress()+"<br>";
Message.InnerHtml+="City:"+ExtendedProfile.getCity()+"<br>";
Message.InnerHtml+="State:"+ExtendedProfile.getState()+"<br>";