Simple date computation in C#
do you happen to have a sample code on how to subtract day tomorrow or 2 days from toda开发者_StackOverflow中文版y? And then I will multiply it by a number depending on its reserved value. I am figuring how to operate a hotel checking in and show its price by asking when the customer checks out, so the price will be ready upon checking in
This should help:
var rate = 100.00;
var totalDays = 2;
var startDate = DateTime.Today.AddDays(-totalDays );
var total = totalDays * rate;
Console.WriteLine("rate: {0} totalDays : {1} startDate: {2} total: {3}",
rate, totalDays, startDate, total);
精彩评论