如何在正確的方式使用屬性裏面的方法。我在互聯網上搜索,但我找不到屬性是使用裏面的方法,將返回值。如何在C#中使用屬性裏面的方法
public class OET
{
public int ShiftTime { get; set; }
public int BreakTime { get; set; }
public int DownTime { get; set; }
public int ProductionTarget { get; set; }
public int IdealRunRate { get; set; }
public int PrductionOneShift { get; set; }
public int RejectedProduct { get; set; }
public int planedProductionTime(int shift, int breaktime) {
shift = ShiftTime;
breaktime = BreakTime;
return shift - breaktime;
}
我想使用屬性從「PlanedProductionTIme」方法獲取價值,它是代碼右上方?
[:資源下載](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/using-properties)。 – Sinatr
只需使用「return this.ShiftTime - this.BreakTime;」不需要您的參數(班次,休息時間)。 – Flocke
沒有使用「篩選」和「breaktime」局部變量的功能。 –