Переполнение Стэка в простенькой программе
пишу тренировочную программу и возникла проблема с переполнением стэка.
using System;
using static System.Console;
using Persons;
namespace firstMainProjecct
{
class Program
{
static void Main(string[] args)
{
int Clients = 1;
int ClientsNum = 0;
int Employees = 1;
int EmployeesNum = 0;
Client[] clientsAr = new Client[Clients];
Employee[] EmployeesAR = new Employee[Employees];
while (true)
{
WriteLine("1)Client menu");
WriteLine("2)Employee menu");
WriteLine("3)setting menu");
WriteLine("4)Exit");
switch (int.Parse(ReadLine()))
{
case 1:
WriteLine("1)Add Clien");
WriteLine("2)Display All Client");
switch (int.Parse(ReadLine()))
{
case 1:
clientsAr[ClientsNum] = new Client(ReadLine(), ReadLine());
break;
case 2:
for (int i = 0; i < clientsAr.Length; i++)
{
WriteLine(clientsAr[i]);
}
break;
default:
break;
}
break;
case 2:
WriteLine("1)Add Employee");
WriteLine("2)Display All Employee");
break;
case 3:
WriteLine("1)Edit Minimum Sum");
break;
default:
break;
}
Clear();
}
}
}
}
И так же библиотека классов -
using System;
namespace Persons
{
public abstract class Person
{
public string Name { get; set; }
public string LastName { get; set; }
public Person(string name, string lastname)
{
Name = name;
LastName = lastname;
}
public virtual void Display()
{
Console.WriteLine($"Name:{Name} LastName: {LastName}");
}
}
public class Client : Person
{
public int Sum
{
get
{
return Sum;
}
set
{
if (value > minSum)
Sum = value;
else
throw new Exception($"Balance can't be less than {minSum}");
}
}
public readonly int minSum = 0;
public Client(string name, string lastName)
: base(name,lastName)
{
Sum = 1;
}
public override void Display()
{
base.Display();
Console.WriteLine($"On a bank account: {Sum}$");
}
}
public class Employee : Person
{
public string post
{
get
{
if (String.IsNullOrWhiteSpace(post))
return post;
else
return "Not found";
}
set
{
if (String.IsNullOrEmpty(value))
post = value;
else
throw new Exception("The field cannot be empty.");
}
}
public Employee(string name, string lastName)
: base(name, lastName)
{
}
public override void Display()
{
base.Display();
Console.WriteLine($"Consists of positions: {post}");
}
}
}
Так же вот сообщение с консоли
Stack overflow.
Repeat 16062 times:
--------------------------------
at Persons.Client.set_Sum(Int32)
--------------------------------
at Persons.Client..ctor(System.String, System.String)
at firstMainProjecct.Program.Main(System.String[])
т.к я ещё начинаю, код достаточно некрасивый и неправильный, но если вам не ссложно, помогите решить проблему с моей ошибкой