So recently we've been looking around for some C# developers and in amongst the usual programming competency and language related stuff I came up with this quick (written) test of understanding of how the language works, you know reference variables, what readonly means, constructor execution order, etc.
You would be surprised how many were unable to answer correctly, whilst taking note that this was for a mid-senior level role:
class TestClass
{
private readonly StringBuilder _stringBuilder;
public TestClass()
{
_stringBuilder = new StringBuilder();
}
void AppendSomething(string apnd)
{
_stringBuilder.Append(apnd);
}
}
Would this code produce a class that 1; Compiles, 2; Allows an instance to be created AND 3; Has a usable AppendSomething method?
class TestClass
{
private static readonly StringBuilder _stringBuilder;
public TestClass()
{
_stringBuilder = new StringBuilder(50);
}
static TestClass()
{
_stringBuilder = new StringBuilder(100);
}
void AppendSomething(string apnd)
{
_stringBuilder.Append(apnd);
}
}
Would this code compile? If so, what is the default length of the StringBuilder? If not, why would it not compile?
------------------
How many of you in a management-ish development role have come up with questions that can trip up people who are meant to know the language, and what were they?
This post has been edited by RudiVisser: 21 July 2012 - 09:17 AM

New Topic/Question
Reply



MultiQuote






|