Skip navigation

Just had a phone interview for a C# Contract position. It was for a major global software company and the client’s objective was merely to screen candidates for a possible second interview face-to-face.

Here is what I was asked:

1) What is IDisposable and what would you use it for ?
2) How do you ensure Thread synchronization ?
3) What are the Sort methods available to you in Generic collections ?
4) Give an example of some C# Attributes ?
5) What is Platform.Invoke used for ?
6) What is Reflection ?
7) How would you implement a Custom Event and its handler ?

Here Are My Answers

1) IDisposable is implemented when you want to provide a deterministic means of freeing resources. Normally you leave this to the Framework Garbage Collector, but sometimes you have resource-intensive classes where you want to explicitly Dispose of resources, so… [Them: That’s OK you’ve got a handle on this]

2) Thread synchronization. Hmmm. Haven’t done many threads, but you want to make sure that variables are not modified haphazardly, so you take out a lock on an arbitrary object and then perform all your processing within that lock. [Them: OK]

3) Sort methods available to you in Generic collections ? Ermmm. Isn’t there ArrayList.Sort ? What else…[Them: That’s OK, We just want quick answers]

4) An Attribute can be applied to say whether a class can be Serialized or not, to provide security e.g. to determine whether or not a method can access the File System…[Them: That’s fine]

5) Platform.Invoke. [Blank] Sorry that one escapes me. [Them: Its for calling unmanaged code. Me: Oh yeah]

6) Reflection is for inspection the meta-data of Assemblies and classes at run-time. Essentially you do this if you need to discover something at run-time that you didn’t know at compile-time…[Them: Cool. You’ve got an understanding of that]

7) Writing a CustomEvent and its handler. OK. Let me start with EventArgs. I would declare a Custom EventArgs class, then a Delegate which would take those Args as a parameter and name that delegate. Then… [Them: Fine. You’ve got a grip on that.]

And then they said “You got a broad range of knowledge of C#.”
I was chuffed.

So now I’m hopeful for a second interview. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: