This is the forum to discuss the Wrox book Professional C#, 3rd Edition by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen; ISBN: 9780764557590
You are currently viewing the BOOK: Professional C#, 2nd and 3rd Editions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
In the Chapter 5 of the 2nd Edition i find a problem about the example of MortimerPhonesEmployees.As follows:
class EmployeeID
{ private readonly char prefix;
private readonly int number;
..........
..........
public override bool Equals(object obj)
{
EmployeeID rhs = obj as EmployeeID;
if (rhs == null)
return false;
if (prefix == rhs.prefix && number == rhs.number)
return true;
return false;
}
}
prefix and number are the private members of the object rhs,why it can be used like the bold?Thanks for the helper!
3rd.Edition Page 100
Note that the field is also public¡ªwe don¡¯t normally need
to make readonly fields private, because by definition they cannot be modified externally (the same principle also applies to constants).