Valentin574140

Hello ,dear friends.

I am a novice at C# and I don't know how I enter a number in console mode.

I mean ,how do I do what in C is done

scanf("%d",&my_var);

Is there a class for that kind of things

Thanks in advance.

Valentine.



Re: Visual C# Express Edition How do I enter an integer value in console mode?

DMan1

Console.Write(1.23);

String s = Console.ReadLine();






Re: Visual C# Express Edition How do I enter an integer value in console mode?

jrboddie

Try this:

Code Snippet

int my_var;

while (int.TryParse(Console.ReadLine(), out my_var) == false)

{

Console.WriteLine("Invalid Number");

}

Console.WriteLine(my_var);





Re: Visual C# Express Edition How do I enter an integer value in console mode?

Valentin

Thanks ,got it working.

Valentine





Re: Visual C# Express Edition How do I enter an integer value in console mode?

Valentin

Sorry, I don't understand your code.

It displays

1.23

and asks a user to enter text,which is strored as a string.

It does not strore numerical value of the input.

Valentine.