paul.catalin_
New member
- Joined
- Jul 6, 2019
- Messages
- 1
- Programming Experience
- Beginner
can someone show me some examples with this class of constructors, methods and overload ??
define 2 employee and for the first one to rais the salary, then display the employees.
i`m very new to programming, i want to learn c#
and i want to know if i started right
```
```
define 2 employee and for the first one to rais the salary, then display the employees.
i`m very new to programming, i want to learn c#
and i want to know if i started right
```
C#:
using System;
namespace ConsoleApp1
{
class employee
{
public string name{ get; set; }
private double Salary;
public double salary
{
get { return Salary; }
set
{
Salary= value;
if (Salary< 0) Salary= 0;
}
}
// constructor de clasa
public employee(string _name= "Neinitializat", double _salary= 0)
{
salary= _salary;
name = _name;
}
//constructor de copiere
public produs (salary s)
{
salary= s.salary;
nsme = s.name;
}
public void citire()
{
Console.WriteLine("NAme:"); name = Console.ReadLine();
Console.WriteLine("Salary:");Salary=double.Parse(Console.ReadLine());
}
public void scriere()
{
Console.WriteLine(name + "," + Salary);
}
}
class Program
{
static void Main(string[] args)
{
}
}
}
```
Last edited by a moderator: