• 0

C#


Question

[C#] Update date

Hi everybody, i have a problem with my C# prog. I'm trying to create Date using console application. The date should run about 40 times and increment by day and month. I was expected to use array for the number of days in a month, and cretae an exception for # days in the leap year. Please if anybody understand my question...help...

Thanks so much

This is some of my code:

using System;

namespace LABI

{

class Date

{

private int day=1, month=1, year=1;

public Date(int d, int m, int y)

{

if (m>0 && m<=12)

for(int i=1; i<=12;i++)

{m+=i;

m = month;}

year = 2004 = y;

day = arr (d);}

public Date(int arrayday)

{

int[]numday = {0,31,28,31,30,31,30,31,31,30,31,30,31};

if (arrayday

{

for(int i=1;i<=31;i++)

day+=i;

}

}

static void Main(string[] args)

{

Console.WriteLine(day + "/" + month + "/" + year);

}

}

}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I don't really understand what you are trying to do but there are quite a few errors in your code.

e.g.: You have 2 contructors but you never call either of them. You can't access the member fields day,month&year in the static main method. This statement is illegal: year = 2004 = y, etc...

If you want to work with dates you could check out some of the built-in classes (DateTime) first.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.