C Sharp Development 101 – A Tutorial Series

In this tutorial series we are going to look at C# Development using the Visual Studio 2010 Express editions.  This will take you from the basics of installing Visual Studio 2010 Express, to the Object Oriented Programming style associated with C# and other languages, dabble in some database access (Access & SQL Server Express) and finally, design a project that will pull all of our knowledge together into a final solution.

We are going to begin by downloading the Visual Studio 2010 express from Microsoft’s website so that we can get started on some C# development.  After the file has been downloaded you will need to have a connection to the Internet so that the program can download the necessary files to complete the install.  For the sake of customization we won’t walk through the rest of the install and will pick up with some add-ons that will make your coding experience easier.

With the Express edition now installed, it is good to know that the express editions of Visual Studio 2010 do not support extensibility.  This means that the ability to install plug-ins and add-ons is not included.  If you happen to acquire or have a full version of Visual Studio 2010 then the option is there for you to add these plug-ins that have helped me out in a tough spot before.

  • Visual Assist X
    • This is probably one of the best applications out there for intellisense and document syntax highlighting.  Now many of you might be saying that Visual Studio already does this.  Yes they do, but not as well as Visual Assist X.  This add-on will look into your added in files such as the Boost library, and retrieve all of the Boost functions and try and piece together a description of what that particular function would do.  Syntax highlighting is the best around with the quick option to do minimal to maximum highlighting.  A must have for the avid programmer but will run you $249 for a one year subscription and $49 maintenance fee every year afterwards.  This price tag might discourage most but take the 30 day trial and take it for a test run.

  • Ghost Doc
    • A product of SubMain, this add-on will allow you to document your code quickly and efficiently using XML markup.  To generate these comments it uses the elements type, parameters of the function as well as its name to generate the comment.  This is especially useful for people who do not enjoy documenting functions in their code.   Most promising add-on if you are looking for code documentation.

  • AnkhSVN
    • A free SVN add-in for Visual Studio that allows you to connect to a repository, browse the branches all within the comfort of the Visual Studio environment.  Very easy to use for people who want to start a community project on Google Code or host their own.  A must have for people who like to collaborate and don’t want to hover over one persons computer to review code.

AnkhSVN logo

All of these have been personally used and are highly recommended for use when developing for the .NET framework.  The next part in this series will go back to an old classic for programmers; Hello World.  We will go through making a project file and printing Hello World to the console as well as on a form.  As always, any problems with the series or if you just have questions post to the comments so that we may learn from each others mistakes and grow as a community.  If you can’t wait until the next post, here is how to start making a Hello World console app.  Until next time, Happy Hacking!

107 thoughts on “C Sharp Development 101 – A Tutorial Series

  1. Just as a side note, you mentioned the express edition, but if you have a .edu e-mail address, you can go to https://www.dreamspark.com/ and download VS 2005, 2008 and 2010 Professional Edition for free from Microsoft… Also Expression Studio 4 Ultimate, Windows Server 2003, 2008, and 2008 R2 Standard editions, Windows Embedded CE 6.0, SQL Server 2008 Developer, etc… This probably isn’t news for many but it would be worth mentioning in the article as I imagine there are a lot of college students here.

  2. I will never use a dot net product. I think I can swing my company to switch to Linux and a whole different toolchain before that happens. (We’re a small shop, and I’m both the in-house and product development IT department.)

    dot-Net was a swipe at Java, in M$ typical embrace-extend-choke fashion, and in order to make their move M$ obsoleted billions of lines of working code by making the “next generation” of Visual Studio totally incompatible with VS6. It wasn’t a next generation at all; it was a totally new and different product with new and different capabilities. Were some of those capabilities good? Yeah, probably. But I’m more concerned with ten years of legacy apps that are no longer supported by any supported M$ development tool.

    Fuck Microsoft and their next new product too. My existing code is now better supported under Linux via WIne than by the company that sold me the original development tools. You hitch your wagon to Microsoft’s horse at your peril.

  3. So many haters! I was very happy to find this post and it’s inspired me to download VS Express and give it a go.

    Not every article on the site suits me either, but instead of complaining, I simply skip it and read the next one.

    Please don’t be put off posting any follow ups to this tutorial, or any similar posts for that matter.


  4. yes please post something more than 3 paragraphs that do not explain anything and a link list next time

    I like this one especially

    “”This will take you from the basics of installing Visual Studio 2010 Express””


    “”For the sake of customization we won’t walk through the rest of the install””

    hella useful! apparently we are too stupid that we need instructions to download a file and run it, but too smart for the rest of the install

    good article

  5. Seriously, this better get followed up with some mad LINQ/generics/FFI wizardry tutorials. Otherwise, it looks like a sponsored ad-post for commercial software.

    Download Python + MatPlotLib + NumPy instead… Your code will run on more machines, not require a giant runtime, and have better long-term support.

  6. The “not-a-hack” comments will never stop will they? I’m guessing that most hack-a-day readers, myself included, enjoy these “non-hack” posts. If we didn’t, the ad revenue from this site would have suffered, and the posts would have stopped a while ago.

    I’m a pretty hardcore c++/python kind of guy, but I’ve been meaning to try c# out for a long time now. Thanks for the tutorial, keep them coming.

  7. Let me also add that the less-technical posts like this, and yes the arduino stuff too, help introduce people who might be proficient in one area to new areas. I’m a software guy, but years ago I started reading sites similar to hack-a-day, which inspired me to dive into the hardware side of things. As a result, today, I spend most of my time working with embedded systems. Which I enjoy a lot more.

    And, you could say, that although there might not be a hack every day, sites like hack-a-day birth a hacker-a-day. Which is just fine in my book.

  8. @amk You’re right that intro-level posts are important, but this is:

    -a link to download VS2010
    -a link to what I assume is a hello world tutorial
    -a high-visibility advertisement for a $250 commercial product
    -links to SVN/autodoc plugins

    Only two of those are useful to beginners, and all the links were broken when I tried them. This looks like an SEO post plain and simple.

    I hope I’m wrong and that there’ll be further tutorials as promised, though. I’ve been meaning to give C# a go; it looks like a nice middle ground between C++ and functional languages/Python. Heck, it’s got a proper “for” statement!

    The main thing delaying me is I’m not sure what the killer application of C# is. I know it’s good with GUIs, but what else? I suspect LINQ might do some sorcery with databases, but haven’t run into a good example yet.

    What do you guys think?

  9. for vim bindings use ViEmu
    I’m using VisualSVN over AnhkSVN
    GhostDoc is overkill since too much commenting hides your code
    Resharper is a must for IDE enhancements

    skip express and go to monodevelop/sharpdevelop it lets you use solutions

  10. @lexi
    > When I want to waste time fixing dangling references, memory leaks, and struggling with poorly supported APIs, I use C++.

    Dude, if C++ is too hard for you, be honest and put it straight: C++ is too hard for me, so I use C#.

    Besides, C# is pretty unportable. Believe me, If you ever would like your app to be portable across linux/windows/mac/symbian – C# is NOT your choice. QT&C++ is WAY better.

  11. Not only unportable, it’s totally useless for embedded development, which _used_ to be the main focus of this site.
    Desktop applications development isn’t interesting. I do plenty of it because I occasionally need a program that doesn’t exist, but I don’t ever want to read about it on a site for hacking.

  12. I can see where people are coming from with this not being what they want from hack-a-day, but I personally like to see a wide variety of stuff, even things that may not qualify as “hacks”. I guess I like things more for technology hobbyists in general than just for those who work with hardware or embedded software.

  13. It surprise me how many people try to cut corners instead applying reliable and proper way, in a long run they only lose time since all they knowledge is worthless when company they dependent on decide to make changes.
    I newer even bother to look at something what tied to single company or platform

  14. @Ralph
    Tutorials are an aid to hacking, therefore not open to flaming.

    I’ve indulged in a little C# in the past and especially enjoyed how easy it was to knock together a small app after an hour or so of reading. Keep this series going, just the basics let those who want to learn finish off on their own steam.

  15. @Necromant

    Portability is not a concern for me, None of my clients ask for portable code. They ask for something that will work in Windows and they want it developed as fast as possible.

    C++ is not to hard for me. I was a c++/QT coder for 3 years before becoming a C# dev. I also had the same mindset at you before I moved over to C# “C# and MS sucks, C++ is the greatest thing since sliced bread” Until all of my clients started requesting C# dev because it saves so much development time. And when portability isn’t an issue, why should I waste time using QT? And when the database/network is the system bottleneck and not the speed of the code, who cares that it’s slower? No one.

    You probably have never even tried using c# and visual studio, thats why you say it sucks. Do you know what commercial QT licenses on windows cost? More than a copy of Visual Studio, I can guarantee it.

    Point is, You get more work done, more clients request it, portability and speed aren’t issues for me, and it pays exactly the same.

  16. To all the hating noobs: Professionals use whatever language is appropriate be that c#, Java, python or whatever. Try broadening your horizons rather than ruling things out on religieous grounds and you will be a better programmer.

    To the guy who wants to still use VB6. Converting VB to C# is trivial and you’ve had 8 years to do it. Plus if you really want to stay in the stone ages windows 98 and VS6 still work as well as they ever did.

  17. I shouldn’t worry, it’s like religion – Anyone who cares about religion to any degree is hysterically over-protective of “their” religion and believes all other religions are wrong. Most of the rest of the world think each religion has reasonable traits but generally will work with whatever floats their boat, will try a bit of everything or ignore the ones they don’t find useful and laughs at the religious nut on the corner who’s getting all upset that no-one is taking him seriously.

    Use what helps you at the time. There will always be someone who thinks what you’re doing is correct and wants to pay you for it. IF it’s for home use, just use whatever is easiest for the job and ignore all the religious nuts telling you you’re coding to the wrong God.

  18. Bob wrote: “To all the hating noobs: Professionals use whatever language is appropriate be that c#, Java, python or whatever.”

    What I observe is that many professionals are even more “religious” when it comes to how they do their work, because they’ve become accustomed to their software/environment for years and thus don’t /know/ or /want to know/ much else. After all, they see it as competition.

    As to C#: What exactly does “appropriate” mean?

    I like to think more of “options” and “possibilities”.

    How well is C# suited for all the mobile computing ahead?

    A colleague of mine connects his phone to an LCD, keyboard and mouse via docking station and this is his everyday working station. Advantage: He has all data right at his fingertips, everywhere, everytime.

  19. C# is slower than Java and less portable.

    C# also has patent encumbrances and Microsoft’s long history of suckering people into investing in their proprietary systems and then strategically abandoning them.

    In the past, migrating to Microsoft platforms like Active Channel or Microsoft Office Accounting have gotten people fired. Small businesses have been bankrupted.

    Just recently, how many people made significant investments of time and money to develop for the Microsoft Kin phones only to have Microsoft drop them after just 6 weeks?

    Maybe you know a Microsoft fanatic that spent months putting all their finances into Microsoft Money just to have it discontinued?

    By contrast, Free Software is something you can depend on. With Free Software you know the file format. With Free Software you can add features. Focus on what you can depend on!

  20. @lexi
    > You probably have never even tried using c# and visual studio, thats why you say it sucks. Do you know what commercial QT licenses on windows cost? More than a copy of Visual Studio, I can guarantee it.

    Surprise, I did. I even did some commertial dev with C#. And during that part of my life I have witnessed what I can call the worst codebase ever.
    If you want something enterprise and fast – use java. This will save you a lot of effort.
    Oh, and btw, VS sucks hard. It’s not even close to a well configured emacs.

  21. > You probably have never even tried using c# and visual studio, thats why you say it sucks. Do you know what commercial QT licenses on windows cost? More than a copy of Visual Studio, I can guarantee it.

    Are there any problems with cryochambers? Anyway, Welcome to the 21st century – QT is LGPL here!

  22. I kind of like C# now. It makes things very simple. In C(++) you have to invest in some good macros and stuff to get the rest of the code size down a bit/manageable. (Speaking from embedded C experience)
    Anyway, something relevant:
    public static extern UInt32 Inp32(UInt32 portAddress);
    public static extern void Out32(UInt32 portAddress, UInt32 data);

  23. @all the Java cheerleaders/C# haters:

    1. C# runs on 3 systems (Linux/MacOS/Windows), not one.

    2. Most C# < 4.0 would compile in Mono and run with trivial changes. I remember the first time I tried compiling VS source with a fairly sizable 3.5 project and was amazed. If you follow SOLID principles, your issues should be trivial.

    3. C# compiles to native code and is blazing fast, so those who claim it is somehow slower than a memory/resource hog like Java obviously have never seen a C# program running on Mono. (Or windows for that matter). Now, If anybody has EVER seen a large scale Java application that didn't pose memory or cpu resource issues I'd like to hear about it, because I haven't seen one in 10 years despite seeing about 30 or so on very serious hardware.

    4. Anybody who suggests that Java is a great enterprise language has either never been involved with a Java enterprise application, or is blissfully proud of each travesty they wreck upon the world. Please stop. Your code sucks and that's why you can't finish a project (please pick any 2 of the following:) on time, on budget and with required functionality.

    5. Anybody who would suggest coding in C++ is simply a matter of adequate expertise has obviously never met your average corporate developer, (or tried to hire a team of them). [Usually Java fan boys, btw] This is no different than somebody in the 90's telling a client that they should bypass VB6 and use C for a Windows GUI/DB app:

    It's absolutely nuts and will result in: needlessly higher costs and a very high probability of failure unless it will only be written by one or two guys and then immediately launched into space without a radio-data link.

    5. 'coding for thirty years' != 'authoritative voice'. I've been coding for over a decade, but I hardly think that any of my earlier experience is more than a conceptual stepping stone to my last three years of work. Maybe people have different experiences, but most people I meet who claim to have been coding for 'n' decades are hopelessly stranded on some technology or methodology that psychologically blocks them from getting up to date. My only doubt is whether the inevitable follow up will be: 'These kids today don't know anything' or 'Offshore development has made it impossible to keep a job in programming'. (The first may be true but is unhelpful, the second is definitely false.)

  24. Anyone who is not programming 1’s and 0’s by hand and winding their own magnetic core memories is a sissy.

    What a waste of finger muscles. But I cannot resist.

    C# is an easy to learn alternative to lots of other languages, learning it will not harm your ability to learn other stuff, there are embedded platforms that use .NET, so it isn’t useless for hackery, and what professionals use and how they use it doesn’t have to concern those of us who are not professional programmers.

    This kind of bitchfest is like a primate feces flinging contest, or gangs attacking someone for the color they wear. The object is to get something done. I can get things done in a handful of languages. They all aggravate me at one time or another. Microsoft provides the express editions free, so expense is not an issue, and there are lots of things to learn before worrying about memory leaks and bullshit, so anything that makes life easier is OK by me.

    So, to any noob unsure of what to do: try it out if it sounds interesting, and look at what has been done with it- Coding 4 Fun or CodeProject has lots of interesting examples, some involving neat hardware. It might teach you something, and you can uninstall it if you discover that it is the antichrist. Never listen to advice from someone who merely denounces. It isn’t useful. Real debates are possible, but if you are a noob, you probably wouldn’t appreciate them, so go make something cool, and use whatever tool you want until you hit a performance brick wall that forces you to learn something else.

  25. to Mark M.

    You just said the things that i would like to say!

    i just want to add:

    to people who said php is better than asp:
    it is real web development.
    it is not code mixed in html or 50 methods which do almost same things but slightly different

    to who said that opensource is better and cheaper:

    in enterprise development that is not always true (reallife case studies says that) because you don’t have any kind of support,

    you don’t know if a bug will be corrected

    opensource code often is really hard to understand/edit because many different style and approaches are mixed together

    sorry for my bad english

  26. This cracks me up. Since when is “hacking” solely associated with electronics or embedded hardware? Uh… if I recall correctly hacking got it’s start in some “old school” diverse areas of study like social engineering. Funny how among a whole bunch of my language is the k00lest folks there isn’t a single reference to Perl?!? I think I’m gonna learn my hacks over at Instructables from now on. Next up… 6800 assembly tutorial

  27. @DaveEaton: lol no one does that any more sad to say. The funny thing is, I’ve found bugs in datasheets for a few “coughMicrochip, coughAnalogDevice” companies that had errors in the register “values” after sanity-checking my self and finally sitting there looking at the returned data on a logic analyzer, finally came to conclusion. People can’t count binary. And just because it’s a multi-billion dollar company, doesn’t mean squat. I think they have like one person proof reading the datasheets or something.

  28. Watch what they do, not what they say.

    Microsoft’s own core applications are being re-written as web services.

    Microsoft Office Web Apps is written in AJAX. That is to say JavaScript.

    If you learn JavaScript & SQL they will still be useful 5 years from now.

    If you learn C# and Access you’ve pretty much wasted your time instead of developing marketable skills.

  29. @DaveEaton Totally agree with you. I’ve given it a go and it makes learning to code a lot easier than simply copying into notepad and compiling.

    The included tutorials are excellent and the language is very similar to other programming languages. Being the noob I am, I find this the be a great way of being introduced to coding.

  30. Oh, Ok AngryCoder.

    Man, maybe I should give back all those 6 figure years of income I’ve made coding C#. SQL will be useful while RDBMS’s dominate for the forseeable future, no thanks to the inch deep developers pushing sql hater bs like Hibernate (“the DB is a glorified string repository for my brain dead objects!”) and NoSQL (“I’m bigger than Google!”). But JS will be (and already is) a dime a dozen.

    My Take:
    I. The Web is the data bus. Future apps will be bindable, throwaway NATIVE apps that hook into it from multiple devices.

    II. HTML5 is the most overhyped baloney since Web 2.0, (“WOW, Google’s Logo …MOVES!!!”) and will fail to end hunger or achieve world peace.

    The whole idea that web hosted apps are going to take over is a wet dream of companies vested in big machines that otherwise don’t have an edge over distributed computing. Ask yourself if the following makes sense:

    1. So, at the point at which ever more processing power is being pushed to the furthest extremes of every device on the network, we are all going to adopt a server hosted/thin client model because it has some overly complex local persistence mechanism?

    2. So, the technology that has only *marginally* successful in replacing MS Outlook, and has been perpetually hyped as ASP, SAAS, and now Cloud based Computing will suddenly be dominant once the next shiny new web standard emerges for the coronation? Wasn’t XHTML and CSS2 supposed to do that?

    3. So, Once we hold the coronation, HTML5 will be frozen, no new features will be added, and no bugs will be found? All browsers shall implement it correctly and the world will live in peace?

    4. So, HTML/CSS/JS is such a superior bundle of interface technology that the same implementation can’t run reliably on four or five browsers with vastly more processing power than the multitude of different devices jumping on the data bus, but somehow HTML5 will work awesomely on every device, every form factor, and every processor, and create an awesome user experience customized for each device as well!

    [Hold on, I’ve got to stop laughing long enough to keep typing]

    5. Somehow HTML/CSS/JS is NEVER as good as a native app on any device you can name, EVER, (All those Iphone and IPad developers are just wasting their time when they could be making web apps!), but HTML5 is going to hit it out of the park.

    I call bull on the whole HTML5, all apps will be browser based hype wagon. Learn native apps and MVVM.

  31. @ Everyone commenting along the lines of “waaaa not a hack”.

    Site is called Hack a Day. I haven’t seen a day yet where among the articles posted, there isn’t been at least one hack.
    If you’re not interested in this article, stop crying and scroll past it. Does it *really* put you out that much that there’s an article that isn’t useful to you?

    Also @that one guy who said he’d stop visiting HaD because of this post:
    I lol’d.

  32. In my opinion, anyone who thinks C++ beats C# clearly has no reasonable knowledge of C#

    “f you learn C# and Access you’ve pretty much wasted your time instead of developing marketable skills.”

    You’re a moron, with the most myopic of viewpoints I’ve ever seen from a ‘developer’.

    “Seriously? Everybody loves C# so much here? What’s wrong with you people?”

    Clearly we’re smarter than you.

    “i Really Like C#, aside from the lack of support for Pointers. but you can always make a DLL in Delphi or C and add it as reference and use within C#. best of both worlds. 8)”

    C# does not lack support for pointers. You need to research PINVOKE.

    “C# is slower than Java and less portable.

    “C# also has patent encumbrances and Microsoft’s long history of suckering people into investing in their proprietary systems and then strategically abandoning them.”

    Nothing but a Microsoft Hater. Plane and simple. The facts do not support your claims.

    “Use PHP for webdevelopment — ASP sucks!
    Use C# for Windows GUI app development — use C++/Qt or C/GTK+ for GNU/Linux GUI app development”

    PHP, really? Come into the 21st century brother, no flying cars, but we have smarty phones.

    … Yup I have lots of time on my hands to bitch at MS haters about near sighted comments from the uninformed. That’s because I use a nice managed framework and get my work done in a lot less time.

    Go bask in the green glow of your iSeries, freakin’ dinosaurs.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.