Help me with simple code
I am learning c# and i attempted to do a console application so i can set my first name, second name and age and when i say " my information " i would like for it to display my information but i am having problem with my If statement and creating and also having a problem creating a variable.
Errors
For if statement : No overload for method 'ReadLine' takes 1 argument.
For variable: Cannot implicitly convert type 'void' to 'string'.
Code of Errors
If statement: if (Console.ReadLine("my information"))
{
Console.WriteLine(Info);
}
Variable: string Info = Console.WriteLine ("Your Name is: " + Fname + " " + Sname + " And your Age is: " + Age);
Full code
Edit: I have fixed one of the error, still having the error for the variable.
Updated code with same variable error
Errors
For if statement : No overload for method 'ReadLine' takes 1 argument.
For variable: Cannot implicitly convert type 'void' to 'string'.
Code of Errors
If statement: if (Console.ReadLine("my information"))
{
Console.WriteLine(Info);
}
Variable: string Info = Console.WriteLine ("Your Name is: " + Fname + " " + Sname + " And your Age is: " + Age);
Full code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string Fname;
string Sname;
int Age;
string Info = Console.WriteLine ("Your Name is: " + Fname + " " + Sname + " And your Age is: " + Age);
string lol = Console.ReadLine();
Console.WriteLine("What is your Name?");
Console.Write("My First Name is: ");
Fname = (Console.ReadLine());
Console.WriteLine("What is your Second Name?");
Console.Write("My Second Name is: ");
Sname = (Console.ReadLine());
Console.WriteLine("What is your Age?");
Console.Write("My Age is: ");
Age = Convert.ToInt32 (Console.ReadLine());
if (Console.ReadLine("my information"))
{
Console.WriteLine(Info);
}
}
}
}
Updated code with same variable error
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string Fname;
string Sname;
int Age;
string Info;
string lol = Console.ReadLine();
Console.WriteLine("What is your Name?");
Console.Write("My First Name is: ");
Fname = (Console.ReadLine());
Console.WriteLine("What is your Second Name?");
Console.Write("My Second Name is: ");
Sname = (Console.ReadLine());
Console.WriteLine("What is your Age?");
Console.Write("My Age is: ");
Age = Convert.ToInt32 (Console.ReadLine());
Info = (Console.WriteLine ("Your Name is: " + Fname + " " + Sname + " And your Age is: " + Age));
if (lol == ("my information"))
{
Console.WriteLine(Info);
}
}
}
}


