The error says that there is a problem with the format of the string and the error line is marked with a comment.
A proper operation of the program could be as follows:
Insert person name:Babar
Insert person age:150
Hello Babar you are 150 years old!
Press any key.
using System;
namespace Person
{
class Person
{
private string name;
private int age;
public Person(string name, int age) //constructor de clase que hace referencia a clase Person y sirve para poner un valor por defecto que no sea Null
{
this.name = name;
this.age = age;
}
public string Name
{
get { return name; }
set { name = value; }
}
public int Age
{
get { return age; }
set { age = value; }
}
}
class Program
{
static void Main(string[] args)
{
int Age;
string Name;
Console.WriteLine("Insert person name:");
Name = Console.ReadLine();
Console.WriteLine("Insert person age:");
Age = int.Parse(Console.ReadLine());
Person p = new Person(Name, Age);
Person constructperson = new Person("javier", 16); //constructor de clase
Console.WriteLine("Hello {0] you are {1} years old!", p.Name, p.Age); //hay fallo en esta línea
Console.WriteLine("Press any key.");
Console.ReadLine();
}
}
}
There is an error in the argument
0
having a square bracket instead of a curly brace:It should be like that:
You must change the
]
to a}
where you want to place the variable{0}
.