C# user input ⌨️

preview_player
Показать описание
C# user input tutorial example explained

#C# #user #input

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("What's your age?");
String name = Console.ReadLine();

Console.WriteLine("What's your age?");
int age = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Hello " + name);
Console.WriteLine("You are " + age + " years old");

Console.ReadKey();
}
}
}
Рекомендации по теме
Комментарии
Автор

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("What's your age?");
String name = Console.ReadLine();

Console.WriteLine("What's your age?");
int age =

Console.WriteLine("Hello " + name);
Console.WriteLine("You are " + age + " years old");

Console.ReadKey();
}
}
}

BroCodez
Автор

Thank you bro I’ve been looking all night for this

DRuger
Автор

Im kinda confused, why didn't you just write int

yourworstnightmare
Автор

FUCKING THANK YOU. My teacher couldnt explain this to me for DAYS

raging
Автор

thanks bro spent hours looking for this

GHOST-fhmw
Автор

A good introduction, but I was looking for how to check for specific keypresses.

samuellundblad
Автор

God, I spent so much time trying to figure this out... I am a little annoyed it was that easy... :/ I kept forgetting one string...

Kelentaria
Автор

I keep having this problem:( "Converting null literal or possible null value to non-nullable type."

LocgicalState
Автор

// user input
Console.WriteLine("please enter your first Name:");
string firstName = Console.ReadLine();
Console.WriteLine("please enter your second Name:");
string secondName = Console.ReadLine();
Console.WriteLine("please enter your last Name:");
string lastName = Console.ReadLine();
Console.WriteLine("please enter your Age:");
string age = Console.ReadLine();
Console.WriteLine("your full name is :\n" + " and your age is " + age +" years old ");

cabdulahiibrahimcisman
Автор

Why my program after input asks me input again My Name? It's simple ReadLine program, but after I input, nothing happens, just another empty line for inputting text???

alexplaytop
Автор

helo, what will happen if the bro was not written and enter again

ecchrck
Автор

what language do you specialize in? is it java?

aditya_asundi