Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
can explain below coding by line?
C#
using System;

class MainClass {
  public static void Main() {
    string t;
    int seconds;

    DateTime dt = DateTime.Now;
    seconds = dt.Second;

    // update time if seconds change
    if(seconds != dt.Second) {
      seconds = dt.Second;

      t = dt.ToString("T");
      Console.WriteLine(t);
    }
  }
}
Posted
Updated 29-Nov-11 21:17pm
v2
Comments
OriginalGriff 30-Nov-11 3:38am    
Reason for my vote of one: Continues to ask for line by line explanations despite polite explanations why we don't do that.
Smithers-Jones 30-Nov-11 4:01am    
Downvoted and reported for the same reason.

Do you have any idea how much work explaining code line by line is? You should do by now, as this is the fourth time today you have asked for it, that I am aware of.

Every single line needs a paragraph of explanation! For example:
int next = r.Next();

Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call the "Next" method to get a new random number, and assign it to the "next" variable.

Can you imagine how long it would take us to explain even a very short code fragment like your example, line by line?

No. It is not going to happen. If you have a specific problem, then ask a question about it. But think first - would you want to sit down for 45 minutes and type up a line-by-line description for no good reason?
 
Share this answer
 
Go here[^], download the book and work your way through it, and everything will become clear.
 
Share this answer
 
The posted code fragment is bad (it doesn't do what is supposed to).
That said, it is very lazy of you asking for a line-by-line explanation. As a developer (wannabe) you should deeply study the programming language you aim to use and read the available documentation, if needed.
 
Share this answer
 
Go here[^], download the book and work your way through it, and everything will become clear; including why your program doesn't work.
 
Share this answer
 
The strictest answer to your question is "Yes".
But we won't.

What would be the point, you wouldn't understand it.
Go back to your teacher and ask him why you bothered to sign up for his class as you seem incapable of grasping rudimentary stuff.

Or buy a book and teach yourself the basics (no pun intended), and then you will know.
 
Share this answer
 
Dear developer,
Have you tried first?
.NET has good facility of Debug, use it. it is step-by-step guide for your code. check this How to debug .NET code
[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900