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;
/*,c,d,e,f,g,h,i;*/

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:
Jonah


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.

thanks

Recommended Answers

All 7 Replies

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.

commented: Good Suggestion +6
commented: you're not wrong, he just can't implement your suggestion +5

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

thanks

commented: N/A +6

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.

commented: He usually isn't. Yeah, that's me! :) +4
commented: It was my mistake. +6

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 : ");
value=Console.ReadLine();

Thanks a lot for all your help

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.