You know how Steve Yegge recommends reading good code and bad code in order to learn from it? Well, I'm looking for good C# samples. Any suggestions?
Someone at work recommended Microsoft's "StockTrader Sample Application". So far it looks promising. You can download the applications here.
Podder : http://joshsmithonwpf.wordpress.com/2008/03/05/podder-v2-has-been-released/ Family.Show : http://www.vertigo.com/familyshow.aspx
Both of these are very good C# WPF applications.
Star Trek Supremacy : http://www.codeplex.com/Supremacy
I've gone through the code base and learned a lot about the latest and greatest.
With the NetMassDownloader, you can download the .Net Framework source. I'd say that's probably among the best C# you can read because not only will you learn how MS does things, but you'll be increasing your knowledge of the internals of the Framework as well.
I would personally recommend against looking on the internet. Maybe someone knows a really good site that I haven't seen, but most of the code I have seen online has been... troubling. On a place like CodePlex or CodeProject or those kinds of sites, you see a lot of people who haven't learned how to do it properly, trying to hack through until they get something working, and then having found that difficult and strange, posting their code with the best intentions for anyone else having trouble with it... There is some fantastic code on sites like that as well, but it's hard to separate the good from the bad, especially if you're trying to learn from it and might not be able to tell at first glance who does and doesn't know what they're talking about.
My suggestion for this would be to read a book, as at least in that case someone had to get it published and likely proofread by other developers (I've seen bad code in books too but it's not as prevalent) There are threads around here that talk about great books for developers, that might be a good place to start, since we're all developers here, so if we recommend a book it's probably not full of wtf code! And if it is, the suggestion would get quickly marked down through the power of peer review ;)
Look forward to seeing some of the responses in this thread, as I'd love some great code to learn from myself!
I would try the source code for Microsoft Enterprise Library for well written, well tested (includes unit tests code) and highly focused components.
If you are looking for decent source code for well written projects I asked a similar question:
Open source C# projects that have extremely high code quality to learn from.
People gave some pretty good suggestions there:
- Scott Hanselman's The Weekly Source Code series (usually managed C#)
- Code written by Microsoft Patterns & Practices team.
- SharpDevelop (written in C#)
- Mono (most of the framework in C#)
- Paint.Net (written in C#)
- NHibernate (written in C#)
- The Castle Project (written in C#)
- xUnit (written in C#)
- .Net Framework Source Code
Jon Skeet's site has a bunch of well thought-out Java and C# articles, with extensive code samples. He's also got an extremely well-commented .NET utilities library (there's a Java one too) that illustrates a number of best practices.