Count Leap year between Two Years

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 1035
-------------------------
Count the Years
-------------------------

-------------------------
Calling Function
-------------------------
var _nopl = NOPl(start.Year , last.Year);

label4.Text=_nopl.ToString();


------------------------
Methode Like Delegate
------------------------

private static int NOPl(int start1, int last1)
{
var count = 0;

for (var year = start1; year <= last1; year++)
{
count += DateTime.IsLeapYear(year) ? 1 : 0;



}
return count;


}

-------------------
What are the Years
-------------------

-------------------------
Calling Function
-------------------------
var _nop = NOP(start.Year, last.Year);

textBox4.Text = _nop.ToString();


------------------------
Methode Like Delegate
------------------------

private static int NOP(int start1, int last1)
{
int year = 0;
//var count = 0;
var yr=0;

for (year = start1; year <= last1; year++)
{
if (Convert.ToBoolean(DateTime.IsLeapYear(year) ? 1 : 0))
{
// count += DateTime.IsLeapYear(year) ? 1 : 0;
MessageBox.Show(year.ToString());


yr = year;
return yr;
}
}

Comments or Responses

Login to post response