views:

457

answers:

5

I would like the SO community let me know what does juniors and proficient .NET Developers should know regarding the following subjects, also some code examples or brainteasers like the ones here will help a lot.

  • System Types

  • Collection and Generics

  • Configuration and Installation

  • Monitoring and Debugging

  • File I/O

  • Globalization

+2  A: 

Let me start you off.

Generics:

What is the difference between an ArrayList and a List<T>? (Boxing/unboxing should come up here).

Stu
You gonna have to be a little more specific if you are looking for boxing. I suggest adding something like ' with regards to the item's type'. Fishing for a specific answer is not good.
leppie
No offense, but if someone cannot point out that ArrayList forces boxing/unboxing for value types and is therefore inferior to List<valuetype>... that's exactly the kind of red flag you are looking for with this question.
Stu
+3  A: 

File I/O

How do you:

  • Read a files content
  • What are file encodings... e.g. UTF-8. Which encoding does .Net use internally? [Would not expect extensive detail, but should know not everything is ASCII]
  • Why could the following code fail with a FileNotFoundException:

    if (File.Exists(name)) { var content = File.ReadAllText(name); }

Globalization

  • What is globalization?
  • What does a globalised application not have. [Should know not to hardcode user display text, date/time/number/... formats]
Richard
For encodings: should also know which encoding .Net uses internally.
Joel Coehoorn
Never mind: needed to edit a spelling error, so I'll add that while I'm at it.
Joel Coehoorn
So why does the example about "File.Exists" fail? (Other than the obvious case of another thread deleting the file after the check but before the call to ReadAllText!)
Hosam Aly
@Hosam: Two reaons: 1) Because the file system is volatile and may change in between when you check and when you use it. 2) Just because a file exists doesn't mean you have permissions to access it.
Joel Coehoorn
[continued] The lessons is that because the file system is volatile, you have to be able to handle the exception when access to the file fails anyway, so making that exception handler work well is a much better place to put your development effort.
Joel Coehoorn
@Joel: yes, now for more difficult questions :-)
Richard
@Joel: The first reason is certainly true, but the second one doesn't seem so IMHO. According to the documentation of File.Exists: "If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path."
Hosam Aly
+4  A: 

Another for generics.

What is the proper syntax (VB or C#) to require that the passed generic type be a type that implements a specific interface?

C# Example with an interface requirement of IHydratable

public static T HydrateObject<T>(IDataReader reader) where T : IHydratable
Mitchel Sellers
+2  A: 

On top of my head, for junior developers:

  • Difference between method overriding and overloading
  • Difference between namespace, class, assembly
  • Value and reference type differences
  • Explain boxing and how to avoid it
muerte
+1  A: 

Whats Wrong with the following code

struct MyStruct
{

   int _a;
   int _b;

   public MyStruct()
   {

   }

public MyStruct(int a,int b)
   {
        _a = a;
        _b = b;
   } 

}
Oscar Cabrero
You can't have a parameterless default constructor in a struct.
dotnetdev
that's correct,but you can change the IL and have one
Oscar Cabrero