私はまだC#を学んでいますが、私は年中休暇を取っています。仕事に戻ってきて、シニアが彼に行く前に年次休暇:else文をconditionを含む1つのメソッドに置き換えます。
public string GetBasketTotalPrice(string basketLocation)
{
var basketTotalPrice = _driver.FindElements(CommonPageElements.BasketTotalPrice);
if (basketLocation.ToLower() == "top")
return basketTotalPrice[0].Text.Replace("£", "");
else
return basketTotalPrice[1].Text.Replace("£", "");
}
private int GetElementIndexForBasketLocation(string basketLocation)
{
return basketLocation == "top" ? 0 : 1;
}
私の代わりにあればelse文を使用して、彼は私がGetElementIndexForBasketLocationの彼の新しい方法を使用したいと仮定しています。
私の質問は、単にこの変更を実装する方法ですか?
おかげ
'var index = GetElementIndexForBasketLocation(basketLocation.ToLower());戻り値basketTotalPrice [index] .Text.Replace( "£"、 ""); ' – FCin
ヒント:GetElementIndex ...から返された0または1は、basketTotalPriceにどのように関係しますか? *新しい*番号は追加されませんでした。 – user2864740