Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Nov 8 '11 at 11:14

This question came from our site for professional and enthusiast programmers.

    
2  
1. Anonymous Methods / Lambdas are essential for truly understanding how LINQ works. 2. Personally I've always hated this "duck extends bird" type of examples in OOP tutorials, infantility doesn't make anything clearer or simplier, and you're talking to veteran programmers. –  Konrad Morawski Nov 8 '11 at 12:01
    
If you do LINQ, then you will have to include lambda's. –  Hans Kesting Nov 8 '11 at 14:30
    
Attributes and Nullable types are a must. –  Boris Yankov Nov 8 '11 at 14:49
    
You should also mention the fact that C# was originally based on and created by the same developer as the Delphi language. Yeah, sink your teeth into that one. Microsoft picks up the creator of Delphi and has him create C#. –  Jerry Dodge Oct 31 '12 at 5:00

6 Answers 6

up vote 12 down vote accepted

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.

share|improve this answer

APress put out a pretty good book a few years ago called .NET 2.0 for Delphi Programmers. The book was released in 2006, shortly after Delphi 2006 was released.

enter image description here

Here's some more detailed information about the book, by the author.

In addition to your training, I'd suggest they pick up a copy of that as well. .NET 2.0 is still a great foundation for learning the framework (you can probably skip the parts on WinForms).

This book presents .Net from a Delphi programmer’s viewpoint. It presents the core concepts of the .Net world in terms of the concepts a Delphi programmer is already familiar with. It is designed to help today’s Delphi programmers not only adopt to Delphi for .NET, but also to C# if that is their preference. It is best to consider the book as the Delphi equivalent of a migration book. We already have migration books for VB6 programmers moving to .NET, and C++ programmers moving to .NET. This book is for Delphi programmers moving to .NET.

And from my own personal experience, I'd suggest they download and install DPack, which will bring along many popular features from the Delphi IDE to Visual Studio.

share|improve this answer
    
The author is a bit of an anti-Delphi evangelist, but the content appears to be relevant to the OP's needs. –  Bruce McGee Nov 8 '11 at 16:21

Going through all that in 2 days will result in very confused people (previous programming background or not). Stick to the core topics in my opinion. I think you'd be firing far so much information at them that it's unlikely to stick.

I'd devote a good bit of time to Generics and the importance / uses of them (as they are an important component of some of the other topics).

I'd also recommend a book to them, and maybe if possible ask them to read it as much as possible before your session?

share|improve this answer

When I started with C# I used this very good (in my opinion) tutorial: http://www.csharp-station.com/Tutorial.aspx

It covers all the introductory topics very well. You can maybe extract a summary from the sections there.

Edit: don't wish to advertise, but if you can get your hands on one of the "C# in a nutshell" books, it's also a good starting point.

share|improve this answer

I was a Delphi programmer, now I program C#. I think your list covers everything a developer needs to know to starting off. You can't teach them everything. Also, I would say that you don't want to become the go to guy for C#. People need to know how to help themselves past a certain point, so you might want a quick run of MSDN and sites like this as invaulable resources.

Also I would say that Interfaces aren't very different from Delphi. In Delphi if you use the TInterfacedObject it will get disposed for you once the last reference is gone, in C# it will also get disposed for you once the last reference is gone (just a bit later, not imediately). If they are familure with that concept already it can help explain garbage collection (although I appreciate they differ widely under the hood, the effect is very similar), just say that it now extends to every type of object or structure.

An architectural note: I agree with Morawski that animal examples are not useful. They encourage people to think inheritance when they should be thinking of composition. This is afterall an engineering discipline, and all successful large engineering systems are built up of many smaller parts (composition). Enormous inheritance trees should be the preserve of the biologists!

share|improve this answer
    
Mentioning MSDN and similar sites makes a lot of sense. Regarding interfaces there are some differences I want to mention. You can cast an interface to an object without hacks for instance. Further they are ref counting manually all the time which is no good idea to begin with. But I think you are right and it comes down to creating trust in garbage collector. Further, Zoology seems not be very popular, I take it. ;) –  Amenti Nov 8 '11 at 13:42

I will make this extremely short.

They are experienced programmers, no sense in teaching them the basics, teach them the stuff that exists in the newer versions of Delphi and C#.

Everything else can be learned from both experience and reading a book. Don't waste your time teaching them "visual studio" they are use to a similar program I am sure.

Garbage Collection - Don't waste your time teaching them about the garbage collector, the amount of times you have to force it to do something is rare, and when you do then you look it up.

Generics and LINQ - Focus on these.

share|improve this answer
2  
I presume when he says Garbage collector he is talking about memory management in .NET as opposed to actually invoking the garbage collector when you want it to do something. The importance of this would depend on what sort of development they do I guess. –  AndrewC Nov 8 '11 at 13:01
    
@AndyC That's how I meant it. Now that I think of it I will even have to add WeakReference to the mix. –  Amenti Nov 8 '11 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.