We interview a lot of people and usually go through at least 3 interviews to select someone for the organization I work in. A recent trend of new developers is baffling me. The newcomer to development do not seem to know any of the basics. These newcomers might know some Linq, Ajax and famous frameworks but they fail at very simple OOP questions and fairly have very little or no idea about the CLR.
Anyway that is not the topic that I was going to write today, I have seen good candidates fail at a this question, which is basic knowledge. I don’t know why but this simple question baffles a lot of people. So I have decided to ask the readers this question.
How do you define a property read only for the outside world and writable for the same assembly classes?
For example I have a class named User where everyone outside the assembly can read the string ‘Name’ property but cannot set it. However the classes inside the assembly is able to set the property. I am further detailing the exlanation.
User myUser = SomeClass.GetUser(); // OK for all classes since all can read it string name = myUser.Name; // This line does not compile if this code is // written in a class that is not in the same // assembly as the type User. But it compiles // if the code is written in the same assembly // that contains the type user. myUser.Name = "C# Developer";
Now all I want is the c# code declaration for the property name that matches my requirement of being read only for the outside world. Write it in the comments section. I will answer the question 24 hours from now.