關於在asp.net中類的繼承問題

來源:互聯網
上載者:User

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>";

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.