How to find next month first day in c#?
.ASPX
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl1" runat="server"
Text="VamsiDotnetStudio"
Font-Bold="true"
Font-Size="XX-Large"
ForeColor="Crimson"></asp:Label>
</div>
<br />
<br />
<div>
<asp:Button ID="Button1"
runat="server"
BackColor="#66CCFF" Font-Bold="true" OnClick="Button1_Click"
Text="Click"
/>
</div>
<br />
<asp:Label ID="Label1" runat="server"
BackColor="Yellow"
Font-Bold="true"
Font-Names="arial"
Text="Check
Here"></asp:Label>
</form>
</body>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
}
protected void
Button1_Click(object sender, EventArgs e)
{
{
DateTime today = DateTime.Today;
DateTime tempDate = today.AddMonths(1);
DateTime tempDate2 = new
DateTime(tempDate.Year, tempDate.Month, 2);
DateTime nextmonthfirstday =
tempDate2.AddDays(-1);
Label1.Text = "Today : " +
today.ToLongDateString();
Label1.Text += "<br /><br
/>Next month first day = ";
Label1.Text += nextmonthfirstday.ToLongDateString();
}
}
}
OUTPUT:
Nice Explanation its very amazing to play with the c#
ReplyDeletefor more of similar kind and other C# interview questions you can refer this link.
c# interview questions