Calculation Retirement age at 60 Years from date of birth

Raj.Trivedi
Posted by Raj.Trivedi under C# category on | Points: 40 | Views : 3307
Take a Datetime picker.

Take a Button and a Label

On button click event write this code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RetirementCalculationAge
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnCalc_Click(object sender, EventArgs e)
{
DateTime dt = Convert.ToDateTime(dtDate.Text);
DateTime dtnow = dt.AddYears(60);
string strDate = dtnow.ToString("dd/MM/yyyy");
label1.Text = Convert.ToString(strDate);

}
}
}

Comments or Responses

Login to post response