Note that there are some explanatory texts on larger screens.

plurals
  1. POC# sorting values with respect to time
    text
    copied!<p>i wanted to create a program like this .<br> For every minute the time should be printed in the format of <code>h:m</code> .<br>For every 5 min it should print "break" <br>this should continue for 24 hours .. like this <br><br> 0:0<br> 0:1<br> 0:2<br> 0:3<br> 0:4<br> break<br> 0:6<br> 0:7<br> 0:8<br> 0:9<br> break<br> 0:11<br> .<br> .<br> .<br> 23:59<br><br></p> <p>i came with a program that solves it ..but i never used <code>DateTime</code> or any time function , i just used <code>Thread.Sleep</code> to dalay printing for 1 minute every time ... i wanted to use some other method other than <code>Thread.Sleep</code> to solve it ... so please guide me .. (sorry for my Bad english) <br><br><br></p> <p>this is how i did with <code>Thread.Sleep</code> .<br> please provide me with any other solutions<br><br></p> <pre><code>using System; using System.Threading; class try22 { public static void Main() { for(int i=0;i&lt;24;i++) { for(int j=0;j&lt;60;j++) { if(j%5 != 0 || (j == 0 &amp;&amp; i == 0)) { Thread.Sleep(20); Console.WriteLine(i+":"+j); } else if(j%5 == 0 ) { Thread.Sleep(20); Console.WriteLine("break"); } } } } } </code></pre> <p><br><br><br> thanks guys i came up with the solution of using actual dates instead of array numbers in my problem <br><br> im getting weird errors with timer .. :( so i used thread.sleep itslef <br></p> <pre><code>using System; using System.Threading; class try22 { public static void Main() { DateTime dt1 = new DateTime(); dt1 = DateTime.ParseExact("0:0", "H:m",null); int cford=dt1.Day+1; for (; dt1.Day!=cford; ) { dt1 = addm(dt1); Console.WriteLine(dts(dt1)); Thread.Sleep(60000); } } public static string dts(DateTime dt) { string tmp = dt.ToString("H:m"); if (dt.Minute % 5 == 0) return "BREAK"; else return tmp; } public static DateTime addm(DateTime dt) { return dt.AddMinutes(1); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload