publicstringFirstName{get;privateset;}// private set is accessible from the entire classpublicstringLastName{get;}// accessible only in constructorpublicICollection<double>Grades{get;}=newList<double>();// property initializer
usingstaticSystem.String;// also common: // using static System.Math;// using static System.Linq.Enumerable;if(IsNullOrWhiteSpace(lastName))thrownewArgumentException(message:"Cannot be blank",paramName:nameof(lastName));
privateList<string>messages=newList<string>{"Page not Found","Page moved, but left a forwarding address.","The web server can't come out to play today."};privateDictionary<int,string>webErrors=newDictionary<int,string>{ [404]="Page not Found", [302]="Page moved, but left a forwarding address.", [500]="The web server can't come out to play today."};
publicstaticIEnumerable<char>AlphabetSubset3(charstart,charend){if((start<'a')||(start>'z'))thrownewArgumentOutOfRangeException(paramName:nameof(start),message:"start must be a letter");if((end<'a')||(end>'z'))thrownewArgumentOutOfRangeException(paramName:nameof(end),message:"end must be a letter");if(end<=start)thrownewArgumentException($"{nameof(end)} must be greater than {nameof(start)}");returnalphabetSubsetImplementation();IEnumerable<char>alphabetSubsetImplementation(){for(varc=start;c<end;c++)yieldreturnc;}}