나는 이미 ArrayList
에 현재 거래일에 3 일을 추가해야하는 버튼이 있습니다.현재 거래일에 3 일을 더해야합니다
어떻게 수행하나요? 당신은 더 이상 코드가 필요하면
private void btnCheckCleared_Click(object sender, EventArgs e)
{
foreach (Transaction item in tranArray)
{
if (What goes here?)
{
DateTime.Today.AddDays(3).ToLongDateString();
}
}
}
은 알려 주시기 바랍니다 다음과 같이
코드입니다. 당신은 그런 일이 필요
namespace TEXT TEXT TEXT
{
public class Transaction
{
//data hiding (blackbox)
//visible only to class itself
//fields (variables)
//4 member variables (instantiate object)
private decimal decAmount;
private DateTime dteTransactionDate;
private string strCheckNumber;
private string strPayee;
private string strTypeTrans;
public bool CheckCleared;
public decimal Amount
{
get
{
return decAmount;
}
set
{
decAmount = value;
}
}
public string CheckNumber
{
get
{
return strCheckNumber;
}
set
{
strCheckNumber = value;
}
}
public string Payee
{
get
{
return strPayee;
}
set
{
strPayee = value;
}
}
public DateTime TransactionDate
{
get
{
return dteTransactionDate;
}
set
{
dteTransactionDate = value;
}
}
public TransactionType TypeTrans;
//constructor
public Transaction(string payee, decimal amount, TransactionType typeTrans, DateTime transactionDate)
{
this.Payee = payee; //assignment operator =
this.Amount = amount; //this is to qualify
this.TypeTrans = typeTrans;
this.TransactionDate = transactionDate;
}
public Transaction(string payee, decimal amount, TransactionType typeTrans, DateTime transactionDate, string checkNumber)
{
this.Payee = payee; //assignment operator =
this.Amount = amount; //this is to qualify
this.CheckNumber = checkNumber;
this.TypeTrans = typeTrans;
this.TransactionDate = transactionDate;
}
//public Transaction()
public override string ToString()
{
return this.TransactionDate.ToShortDateString() + " " + this.Amount.ToString("C") + "\t" + this.TypeTrans;
}
}
}
귀하의 질문에 명확하지 않다, 당신은 그것을 조금 더 설명 할 수 있습니까? –
Transaction 클래스는 어떤 모습입니까? 그것을 수정할 수있는 DateTime 필드가 있습니까? 그리고 우리는 왜 당신이 "만약"조건으로 원하는 것을 알고 있습니까? –
글쎄, 당신은 거래를하고있어, "if"는 아마도 거래 클래스의 어떤 것에 조건부 체크를해야 할 것이다. 그래서 if는 if (item. [Property] == [value])와 같을 것입니다. 또한 Transaction 클래스의 일부 속성을 설정하여 업데이트해야합니다. (DateProperty) = item. [DateProperty] .AddDays (3); – Aaron