Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m a Delphi and C# coder and have been given the assignment to introduce the m

ID: 642233 • Letter: I

Question

I'm a Delphi and C# coder and have been given the assignment to introduce the most fundamental concepts of .Net/C# to my coworkers in some trainings. They are seasoned Delphi Win32 coders but still use an fairly old version, so they aren't familiar with some language features which are commonplace today like generics and they never used .Net before.

Now I'm thinking about the best way to tackle this. Which are the most predominant topics I should cover? I will have maybe 1-2 days for this so I can't delve into specifics too far but have to give them a good birds eye view especially of the features that will matter to them.

I plan to emphasize the differences to Delphi, I think this will help them. I'd like to build a small Zoo-application and add something to it for every step I explain. So they can have a look at the created examples later whenever they want.

My topics so far:

Short introduction of .Net, CLI, CLR
Short introduction of Visual Studio
Showing class/object equivalents, inheritance, creating some objects Animal->Cat->Tiger, explaining Namespace on the way
Garbage Collection and Interfaces (very different from Delphi), Bird gets ICanFly
Events / Delegates (short multicast example), Ape calls all other apes because he found a bunch of bananas or something like that
Generics, creating generic animal list
LINQ, query animals by categories
Parallel Task Libary, the same but this time multithreaded
Some topics I'm not sure I should include:

Attributes
Operator Overloading
Anonymous Methods / Lambdas
Nullable Types
Reflection
P/Invoke
Maybe this should be delayed to a second session, maybe its too much for the beginning, I'm not sure.

I'm also undecided if I should include the coming asynchrony functionality in .Net 4.5. Maybe this is premature.

Then I will have to introduce WPF but I think this should be a question for itself.

Explanation / Answer

As someone who made that transition myself many years ago (and you say they're on an older version), I can recall my biggest stumbling blocks being:

No top-level variables, procedures or functions. Everything must be in a class, like Java. Utility methods can be exposed in a static class (if absolutely necessary).

Namespaces, especially if they've had any exposure to the early "Delphi.NET" implementations which butchered them. Make sure you spend some time explaining not just what namespaces are but how to use them effectively, otherwise you're very likely to see everything jammed into one or two top-level namespaces, just as it would be in Delphi Win32.

Generics were new, but it only took a few minutes to get the hang of them, so I wouldn't plan to waste a lot of time explaining them. Do briefly explain the difference between C++ templates, type erasure (Java) and reified generics (.NET) and why they shouldn't use List<object> when a List<int> will do (boxing, etc.).

Enumerator blocks are used everywhere in good-quality C# code. Make sure you explain what an IEnumerable<T> is and how to use yield. A lot of .NET newbies have trouble with this.

Auto properties.

The entire code structure itself is fundamentally different. In particular, there are no forward declarations. Take some time to explain how a class is supposed to be laid out in C#. Although obviously some of it is up to personal preference/coding conventions, generally you see fields first, then constructors, then methods, then properties (sometimes methods can be interspersed with properties).

Other things I'd recommend touching on:

Explain that the accepted practice in C# is to declare variables as near as possible to the time they are first assigned, preferably on the same line, not at the beginning of methods.

Explain constructors, their syntax, how they don't have names like "Create", and how they can't be virtual. Explain the difference between a destructor and a finalizer, and how finalizers should never be used unless you're implementing the IDisposable pattern to deal with unmanaged resources.

Speaking of which, explain IDisposable and stress that anything which implements IDisposable has to be wrapped in a using (or a try-finally with explicit Dispose).

Other naming convention transitions that will drive you up the wall if you don't mention them up front: Classes don't begin with "T", fields don't begin with "F", etc.

Also a little bit about garbage collection, as you mention, although there's really not much to explain here. There's no Free anymore, and that's pretty much the end of the story. Interfaces are also pure interfaces and don't have weird reference-counting cruft.

Don't just focus on the differences; explain the similarities too. For example: Class methods/static methods, virtual/override vs. member hiding, primitive data types are mostly the same, struct/record are similar, etc.

Save LINQ, TPL, and any other "unique" C#/.NET stuff for the second day. Really, it's more important to focus on core language/framework issues first.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote