Answer the question
In order to leave comments, you need to log in
When running a console application in C #, it gives "Stack overflow." how to fix?
Here is the code, I can't find the error
using System;
namespace Projects
{
class Worker
{
public string name;
public int Age{
get => Age;
set
{
if(Age > value)
{
Console.WriteLine("Error");
}
else
{
Age = value;
}
}
}
public int ID {get;set;}
public int Pay {get;set;}
public Worker(){}
public Worker(string name,int Age,int ID,int Pay){
this.name = name;
this.Age = Age;
this.ID = ID;
this.Pay = Pay;
}
public void About()
{
Console.WriteLine("{0},{1},{2},{3}",name,Age,ID,Pay);
}
}
}
using System;
namespace Projects
{
class Program
{
static void Main(string[] args)
{
Worker Thomas = new Worker("Thomas",24,0467,30000);
Thomas.About();
Console.ReadLine();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question