Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: coloring a cell via datagridview cellformatting event Pin
OriginalGriff19-May-18 19:55
mveOriginalGriff19-May-18 19:55 
AnswerRe: coloring a cell via datagridview cellformatting event Pin
leone24-May-18 11:13
leone24-May-18 11:13 
QuestionI want to read a value from a gridview cell using button event, something i'm not getting right here. Pin
Ngqulunga19-May-18 2:02
Ngqulunga19-May-18 2:02 
Questioni need to save me textbox data to separate line in notepad Pin
Mohamed Fahad M18-May-18 23:41
Mohamed Fahad M18-May-18 23:41 
AnswerRe: i need to save me textbox data to separate line in notepad Pin
OriginalGriff18-May-18 23:59
mveOriginalGriff18-May-18 23:59 
AnswerRe: i need to save me textbox data to separate line in notepad Pin
Dave Kreskowiak20-May-18 5:33
mveDave Kreskowiak20-May-18 5:33 
QuestionMy code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Member 1383451318-May-18 21:59
Member 1383451318-May-18 21:59 
AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
OriginalGriff18-May-18 22:00
mveOriginalGriff18-May-18 22:00 
Compiling does not mean your code is right! Laugh | :laugh:
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.

So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.

Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input   Expected output    Actual output
  1            2                 1
  2            4                 4
  3            6                 9
  4            8                16
Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
C#
private int Double(int value)
   {
   return value * value;
   }

Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Richard MacCutchan18-May-18 23:45
mveRichard MacCutchan18-May-18 23:45 
AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Implements Master Yoda21-May-18 4:34
Implements Master Yoda21-May-18 4:34 
QuestionQuestion in principal regarding writing an Outlook Plugin Pin
Jim60718-May-18 0:35
Jim60718-May-18 0:35 
AnswerRe: Question in principal regarding writing an Outlook Plugin Pin
Eddy Vluggen18-May-18 1:23
professionalEddy Vluggen18-May-18 1:23 
GeneralRe: Question in principal regarding writing an Outlook Plugin Pin
Jim60718-May-18 1:39
Jim60718-May-18 1:39 
GeneralRe: Question in principal regarding writing an Outlook Plugin Pin
Eddy Vluggen18-May-18 13:13
professionalEddy Vluggen18-May-18 13:13 
AnswerRe: Question in principal regarding writing an Outlook Plugin Pin
Gerry Schmitz18-May-18 8:14
mveGerry Schmitz18-May-18 8:14 
QuestionApp pool is crashing due to memory leakage Pin
Anoop Mehra17-May-18 18:22
Anoop Mehra17-May-18 18:22 
GeneralRe: App pool is crashing due to memory leakage Pin
Randor 17-May-18 18:45
professional Randor 17-May-18 18:45 
AnswerRe: App pool is crashing due to memory leakage Pin
OriginalGriff17-May-18 20:04
mveOriginalGriff17-May-18 20:04 
GeneralRe: App pool is crashing due to memory leakage Pin
Anoop Mehra17-May-18 22:59
Anoop Mehra17-May-18 22:59 
GeneralRe: App pool is crashing due to memory leakage Pin
OriginalGriff17-May-18 23:26
mveOriginalGriff17-May-18 23:26 
Questionc# array Pin
swathiii15-May-18 21:00
swathiii15-May-18 21:00 
SuggestionRe: c# array Pin
Richard MacCutchan15-May-18 21:30
mveRichard MacCutchan15-May-18 21:30 
AnswerRe: c# array Pin
OriginalGriff15-May-18 21:34
mveOriginalGriff15-May-18 21:34 
GeneralRe: c# array Pin
swathiii15-May-18 21:50
swathiii15-May-18 21:50 
GeneralRe: c# array Pin
OriginalGriff15-May-18 21:58
mveOriginalGriff15-May-18 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.