There are three types of price in my application price1,price2 and price3. If price1 has priority over price2 and price 2 has priority over price3. If price 1 is not available then variable finalprice is assigned price 2 if price 2 is not available then the variable finalprice is assigned price3.
I am getting those three prices from a list of the following class type -
I am passing the list of price to my update function like this
Now, I am wondering if there is a short and efficient way in which I can assign my finalprice variable the value of price based on availability?
Or would I have to follow the If Else pattern only ?
I am getting those three prices from a list of the following class type -
C#:
class ItemDetails
{
public decimal Price1 { get; set; }
public decimal Price2 { get; set; }
public decimal Price3 { get; set; }
}
C#:
public void Update(List<ItemDetails> itemDetailsList)
{
foreach( var items in itemDetailsList)
{
decimal finalPrice = ???;
}
}
Or would I have to follow the If Else pattern only ?
Last edited by a moderator: