Home > Net >  Ask how to use c # for grammar or other optimization code below
Ask how to use c # for grammar or other optimization code below

Time:01-05

Ask how to use c # for grammar or other optimization the following code
 
Int iWTian=0;//(per week) on the day of the library value time less than now -- on the
If (the Convert. ToDateTime (DateTime. Now. ToString (wTime)) & lt;=a DateTime. Now) {iWTian=7; }//on the 1 week

Int iWeek=the Convert. ToInt32 (DateTime. Today. DayOfWeek. ToString (" d "));//the current week, week number formatting 0 to 6
Int iTian=0;//increase the number of days


The switch (wDay)
{
Case ", ":
If (iWeek==0) {iTian +=iWTian; }
If (iWeek==1) {iTian=6; }
If (iWeek==2) {iTian=5; }
If (iWeek==3) {iTian=4; }
If (iWeek==4) {iTian=3; }
If (iWeek==5) {iTian=2; }
If (iWeek==6) {iTian=1; }
break;
Case "a" :
If (iWeek==0) {iTian=1; }
If (iWeek==1) {iTian +=iWTian; }
If (iWeek==2) {iTian=6; }
If (iWeek==3) {iTian=5; }
If (iWeek==4) {iTian=4; }
If (iWeek==5) {iTian=3; }
If (iWeek==6) {iTian=2; }
break;
Case "2" :
If (iWeek==0) {iTian=2; }
If (iWeek==1) {iTian=1; }
If (iWeek==2) {iTian +=iWTian; }
If (iWeek==3) {iTian=6; }
If (iWeek==4) {iTian=5; }
If (iWeek==5) {iTian=4; }
If (iWeek==6) {iTian=3; }
break;
Case "three" :
If (iWeek==0) {iTian=3; }
If (iWeek==1) {iTian=2; }
If (iWeek==2) {iTian=1; }
If (iWeek==3) {iTian +=iWTian; }
If (iWeek==4) {iTian=6; }
If (iWeek==5) {iTian=5; }
If (iWeek==6) {iTian=4; }
break;
Case "four" :
If (iWeek==0) {iTian=4; }
If (iWeek==1) {iTian=3; }
If (iWeek==2) {iTian=2; }
If (iWeek==3) {iTian=1; }
If (iWeek==4) {iTian +=iWTian; }
If (iWeek==5) {iTian=6; }
If (iWeek==6) {iTian=5; }
break;
Case "five" :
If (iWeek==0) {iTian=5; }
If (iWeek==1) {iTian=4; }
If (iWeek==2) {iTian=3; }
If (iWeek==3) {iTian=2; }
If (iWeek==4) {iTian=1; }
If (iWeek==5) {iTian +=iWTian; }
If (iWeek==6) {iTian=6; }
break;
Case "six" :
If (iWeek==0) {iTian=6; }
If (iWeek==1) {iTian=5; }
If (iWeek==2) {iTian=4; }
If (iWeek==3) {iTian=3; }
If (iWeek==4) {iTian=2; }
If (iWeek==5) {iTian=1; }
If (iWeek==6) {iTian +=iWTian; }
break;
Default: break;
}

CodePudding user response:

 
String dataWk="day";
DateTime today=DateTime. Now;
for(int i=0; i <7. I++)
{
DateTime temp=today. AddDays (I);
If (temp. ToString (" DDD "). The Contains (dataWk))
{
TbLog. Text=temp. ToString ();
break;
}
}
  •  Tags:  
  • C#
  • Related