I am building a program with Name, Roll No., Marks in different subjects, Total and Average. Just wanted some advice. Pls encourage me.

class Report

static void Main ()


string s = " ";
int a;

Console.WriteLine ("Enter the Name:");
s= Console.ReadLine ();

Console.WriteLine ("Enter the Roll No.:");
a=Convert.ToInt32(Console.ReadLine ());

Marks in English:\nMarks In Hindi:\nMarks in Maths:\nMarks in Social:\nMarks in G.K.:\n");

b=Convert.ToInt32(Console.ReadLine ());
c=Convert.ToInt32(Console.ReadLine ());
d=Convert.ToInt32(Console.ReadLine ());
e=Convert.ToInt32(Console.ReadLine ());
f=Convert.ToInt32(Console.ReadLine ());
g=Convert.ToInt32(Console.ReadLine ());
h=Convert.ToInt32(Console.ReadLine ());
i=Convert.ToInt32(Console.ReadLine ());*/



When I am asked to enter name it is not coming on the side ways

it is coming like this

Enter the Name:

I want it to come in this way

Enter the Name: Jonah

please help what I must do to make my input name to be typed just beside " Enter the Name:" instead of next line.


7 Years
Discussion Span
Last Post by sknake

Hi Jonahmano! This can be done very easy.
Instead of WriteLine, use Write.
WriteLine writes a string and put a extra carriage return character after, Write does not.

Votes + Comments
you're not wrong, he just can't implement your suggestion
Good Suggestion

ddanbe you are wrong.

I tried to change WriteLine with Write and I got a bunch of errors

My code is working so please makes changes in my code and paste it back.

Let me compile and see


Votes + Comments

No, ddanbe is correct. If you use Console.Write() then read the line it will not advance the cursor to the next line. You probably made modifications to the wrong section of the code. Here are the lines in question:

Console.WriteLine ("Enter the Name:");
Console.WriteLine ("Enter the Roll No.:");

Change those to Console.Write(); and please be careful when telling ddanbe when is wrong. He usually isn't.

Votes + Comments
It was my mistake.
He usually isn't. Yeah, that's me! :)

Also notice you don't have an extra Console.ReadKey() or ReadLine() as a last statement to keep the console on the screen. Use code tags when you post code, just as sknake did.


@jonahmano: ddanbe you are wrong.
No. He gave you a solution. Use Write Method.

Console.Write("Enter Name : ");

Please mark this thread as solved as danny provided a solution to your question and good luck!

If you are still having issues please post back on this thread and we will be more than happy to help you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.