Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
QuestionReading DVD multi session structure(s) Pin
kiskeya2-Apr-16 8:36
kiskeya2-Apr-16 8:36 
QuestionCan share different invocations of an application the same static data Pin
Wolfgang Kurz2-Apr-16 8:00
professionalWolfgang Kurz2-Apr-16 8:00 
AnswerRe: Can share different invocations of an application the same static data Pin
Richard Andrew x642-Apr-16 9:40
professionalRichard Andrew x642-Apr-16 9:40 
AnswerRe: Can share different invocations of an application the same static data Pin
Brisingr Aerowing2-Apr-16 14:27
professionalBrisingr Aerowing2-Apr-16 14:27 
GeneralRe: Can share different invocations of an application the same static data Pin
Wolfgang Kurz2-Apr-16 21:13
professionalWolfgang Kurz2-Apr-16 21:13 
AnswerRe: Can share different invocations of an application the same static data Pin
Bernhard Hiller4-Apr-16 0:37
Bernhard Hiller4-Apr-16 0:37 
Questionhelp me in this code Pin
Kulbeer sidhu2-Apr-16 2:18
Kulbeer sidhu2-Apr-16 2:18 
AnswerRe: help me in this code Pin
OriginalGriff2-Apr-16 2:31
mveOriginalGriff2-Apr-16 2:31 
First off, don't use int.Parse - use int.TryParse instead:
C#
int a;
if (!int.TryParse(Console.ReadLine(), out a))
   {
   // Report problem to the user - he typed wrong!
   ...
   }
else
   {
   // The value is fine.
   ...
   }
That way your code won't crash if you mistype a number - int.Parse will throw an exception.

Second, look at your code:
C#
if(a <= 0)
    do
        Console.WriteLine("Number must be greater than 0");
    while (a > 0) ;

If you value is greater than zero it won't even get to the loop!
And if it did, all it would do is print the same line forever...

Probably what you want is something like:
C#
if (a > 0)
   {
   while (a > 0)
      {
      // Do something
      ...
      a--;
      }
   }
else
   {
   ...

Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: help me in this code Pin
Ratul Thakur2-Apr-16 4:15
Ratul Thakur2-Apr-16 4:15 
AnswerRe: help me in this code Pin
Ratul Thakur2-Apr-16 3:52
Ratul Thakur2-Apr-16 3:52 
GeneralRe: help me in this code Pin
Sascha Lefèvre2-Apr-16 4:50
professionalSascha Lefèvre2-Apr-16 4:50 
GeneralRe: help me in this code Pin
Ratul Thakur2-Apr-16 6:33
Ratul Thakur2-Apr-16 6:33 
GeneralRe: help me in this code Pin
F-ES Sitecore3-Apr-16 4:15
professionalF-ES Sitecore3-Apr-16 4:15 
GeneralRe: help me in this code Pin
Pete O'Hanlon3-Apr-16 4:51
mvePete O'Hanlon3-Apr-16 4:51 
GeneralRe: help me in this code Pin
F-ES Sitecore3-Apr-16 4:56
professionalF-ES Sitecore3-Apr-16 4:56 
GeneralRe: help me in this code Pin
Ratul Thakur3-Apr-16 7:46
Ratul Thakur3-Apr-16 7:46 
GeneralRe: help me in this code Pin
Sascha Lefèvre3-Apr-16 13:11
professionalSascha Lefèvre3-Apr-16 13:11 
GeneralRe: help me in this code Pin
F-ES Sitecore3-Apr-16 22:38
professionalF-ES Sitecore3-Apr-16 22:38 
JokeRe: help me in this code Pin
Pete O'Hanlon3-Apr-16 22:57
mvePete O'Hanlon3-Apr-16 22:57 
AnswerRe: help me in this code Pin
Sascha Lefèvre2-Apr-16 5:10
professionalSascha Lefèvre2-Apr-16 5:10 
GeneralRe: help me in this code Pin
OriginalGriff2-Apr-16 6:16
mveOriginalGriff2-Apr-16 6:16 
GeneralRe: help me in this code Pin
Mycroft Holmes2-Apr-16 13:32
professionalMycroft Holmes2-Apr-16 13:32 
GeneralRe: help me in this code Pin
Sascha Lefèvre2-Apr-16 14:15
professionalSascha Lefèvre2-Apr-16 14:15 
GeneralRe: help me in this code Pin
Mycroft Holmes2-Apr-16 16:32
professionalMycroft Holmes2-Apr-16 16:32 
AnswerRe: help me in this code Pin
Suresh73-Apr-16 5:55
Suresh73-Apr-16 5:55 

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.