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
void Main() | |
{ | |
Console.WriteLine("Do you want to continue? Enter Y for Yes or N for No"); | |
var answer = Console.ReadLine(); | |
if (answer.ToUpper() != "Y" && answer.ToUpper() != "N") | |
{ | |
throw new InvalidAnswerException(); | |
} | |
} |
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
void Main() | |
{ | |
Person firstPerson=new Person(new DateTime(2001, 10, 16)); | |
// Unrestricted access to FirstName and LastName | |
firstPerson.FirstName="John"; | |
firstPerson.LastName="Jones"; | |
// Cannot access Date Of Birth, other than via consructor or within class membes internally | |
//firstPerson.DateOfBirth= new DateTime(1926, 03, 27); |
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
void Main() | |
{ | |
Console.WriteLine(new PersonBuilder().WithValidDetails().Build()); | |
Console.WriteLine(new PersonBuilder().WithValidDetails().WithValidAddress().Build()); | |
} | |
public class Person{ | |
public string FirstName {get;set;} | |
public string LastName {get;set;} | |
public Address Address{get;set;} |
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
/* | |
Required Namespace | |
System.Xml.Serialization | |
*/ | |
public class Person | |
{ | |
public string Name {get; set;} | |
public int Age {get;set;} | |
public Address Address{get;set;} |