Created
November 19, 2015 19:29
-
-
Save Jore2/3d99f5a738398bb12bb7 to your computer and use it in GitHub Desktop.
01.Person
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _01.Person | |
{ | |
public class Person | |
{ | |
private string name; | |
private int age; | |
private string email; | |
public string Name | |
{ | |
get | |
{ | |
return this.name; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
else | |
{ | |
this.name = value; | |
} | |
} | |
} | |
public int Age | |
{ | |
get | |
{ | |
return this.age; | |
} | |
set | |
{ | |
if (value <1 || value>100) | |
{ | |
throw new ArgumentException("Age are "); | |
} | |
else | |
{ | |
this.age = value; | |
} | |
} | |
} | |
public string Email | |
{ | |
get | |
{ | |
return this.email; | |
} | |
set | |
{ | |
if (value != null && !value.Contains("@")) | |
{ | |
throw new ArgumentException("Age are "); | |
} | |
else | |
{ | |
this.email = value; | |
} | |
} | |
} | |
public Person(Person per):this(per.Name,per.Age,per.Email) | |
{ | |
} | |
public Person (string name,int age,string email) | |
{ | |
this.Name = name; | |
this.Age = age; | |
this.email = email; | |
} | |
public Person (string name,int age):this(name,age,null) | |
{ | |
} | |
public override string ToString() | |
{ | |
return string.Format("{0},{1},{2}",this.Name,Age,Email); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment