如何在c#中使用接口時調用同一類中的方法內的方法?我有錯誤時通過(對象作爲基類)試圖訪問。方法在接口c中的方法內的調用方法#
interface IAccount
{
string fullName{get;set;}
void Balance();
}
public class User : IAccount
{
public string fullName { get; set; }
public int balance = 10000;
public User(string firstName, string lastName)
{
fullName = firstName + lastName;
}
public void IAccount.Balance()
{
Console.WriteLine("Account balance-" + this.balance);
}
public void MyBalance()
{
Console.WriteLine(" My balance");
IAccount.Balance();
}
}
我們可以看到一些代碼嗎? – Neel
和您嘗試調用方法內的方法的代碼? – Carsten
錯誤是什麼?請在將來使用**編輯**按鈕更新您的問題。 – Sayse