Learning C# in 21 Days - Progress and Questions thread.

Associate
Joined
13 May 2004
Posts
1,491
Location
Wales, Wrexham
Okay, i havea copy of SAMS Teach Yourself C# in 21 Days in front of me, and i have just finished reading Day 1, and even though the theory behind the code was quite tough, i think i sort of understand it.

So i'm going to post in here my progress, okay it may take me longer than 21 days, but 21 days is my initial target.

Okay, so in Day one i've learned the basics of what programming entails, the idea behind C#'s introduction to the world and so on, reasons why it is a good programming language to learn and basic principles behind all programming languages.

There was a part on Encapsulation, Polymorphism and Inheritance, and i want to write out what i take them as, and wouldn't mind knowing whether i am along the right lines or whether i have grasped the wrong end of the stick.

Encapsulation refers to Objects effectively, an object that defines a circle outputs a circle, though the way the circle is worked out is 'encapsulated' in such a way that it keeps the user oblivious. If the object outputs a circle, all the inner workings out are irrelevant

Polymorphism covers quite a few things, if you were to feed an object certain arguments and depending on what arguments are fed into the object, different outputs are created - based on the information fed in, the output could be a square, circle, triangle.

Inheritance i find quite hard to explain, and i know the above two are rather hazy, so if anyone can summarize them in a way that makes more sense, i would be grateful!

As for the actual code itself, you are asked to copy the code that is in the book without any explanation as to what the code does, or why it is there.

Hello World was easy enough, the first WinForm application was a bit different however, for example

private TextBox txtBox1;

I assume this is defining a textbox with the name txtBox1?

Then further along

this.txtBox1.Location = new System.Drawing.Point(16, 32);

The (16, 32) appear to be co-ordinates, it is defining txtBox1's location however what does the whole 'this' thing actually mean, is there a way you can explain it? Obviously it has to be there to work, but what exactly does it do?

Sorry if i sound like a complete newbie, but well.. i am. (to C# at least!)
 
Inheritance :

You could have a class that defines a dog, which eats sleeps and (you know).

You could then define classes of types of dog which inhreit from dog. IE a labrador might have long legs, and a sausage dog may have small legs, but they both still eat, sleep and (you know).

I think thats correct!

this refers to the current instance of an object.
 
That actually makes quite a bit of sense, so each new dog 'Inherits' the properties defining a dog, yet gains new properties based on whatever else we may do to it.

Trying to get a headstart on Uni isnt as easy as i'd first thought!
 
Don't want to knock you off course, but I'd really question using WinForms at this stage.

Console applications (i.e. command prompt windows) are a much better environment for learning the basics :)
 
Don't want to knock you off course, I'd really question jumping in to WinForms at this stage.

Console applications (i.e. command prompt windows) are a much better environment for learning the basics :)

While i would agree it would keep things much simpler, i'm following the course of the book - as i skim through most of the later lessons appear to contain console.writeline and so on, so i imagine this was an example - though being curious i just wanted to know.. XD
 
sorry kind of irrelevent where you learnt, i was kinda meaning instead of saying he isnt right you should try and help! :)

I'm not saying he is or is not right. What I'm saying is that anyone who thinks they can learn a language in 21 days needs mental help. It takes time, it takes trying to all sorts of carp with the language to understand one. Buying a book and following examples is probably the worst way of learning a language IMO. Like many threads in here, I recommend learning by doing. Let him set himself a task "by December I want to build an email client" that approach starts you on the path to learning a language, reading a one these "21 days" books is pointless.
 
I'm not saying he is or is not right. What I'm saying is that anyone who thinks they can learn a language in 21 days needs mental help. It takes time, it takes trying to all sorts of carp with the language to understand one. Buying a book and following examples is probably the worst way of learning a language IMO. Like many threads in here, I recommend learning by doing. Let him set himself a task "by December I want to build an email client" that approach starts you on the path to learning a language, reading a one these "21 days" books is pointless.

I am not under the illusion that i can learn the language in 21 days, and i don't think the book even intends you to teach it to a good enough level after 21 days, all i wanted to do was pick a decent method to start from scratch, i have no belief i will be anything other than below average when the 21 days are up.

Although i do respect your points as well, it does make me want to follow an internet tutorial, the book contains far too much theory, although that could come in handy in the future.

I doubt i'll be building an Email client by december, but that would be a decent goal ;p
 
I'm not saying he is or is not right. What I'm saying is that anyone who thinks they can learn a language in 21 days needs mental help. It takes time, it takes trying to all sorts of carp with the language to understand one. Buying a book and following examples is probably the worst way of learning a language IMO. Like many threads in here, I recommend learning by doing. Let him set himself a task "by December I want to build an email client" that approach starts you on the path to learning a language, reading a one these "21 days" books is pointless.

ah sorry, my bad.

i do agree learning whilst doing is best (for me anyway) but i also understand what works for some doesnt for others.
 
I think it can work both ways. I learnt SQL Server by the book but was lucky enough to have previous DB experience and a huge commercial system to jump straight into in parallel with my learning once I was more accomplished.

That said, I am currently learning ASP.NET (C#) and although I bought a book, I've again just gone head on into a project to get myself into it.
I was coming from an exclusive ASP background for the last 4 years so for me this works better. Once I actually got my head around syntax and my classes defined I was away. I've found it much more fun as well to actually experience all the weird and wonderful trials the books don't tell you about. So, to summarise, I agree with dangerstat - learn by doing!!!
 
Best way to learn is to do. Programming concepts are useful in chanelling your thinking and problem solving so that you create good code. You dont need to use inheritance or polymorphism to cod but they are logical steps that will lead you to code faster and more structured.

If no ones mentioned about the 'this' keyword. All it does is reference members of the current object so if you have a class then you can reference the member variables of that class using 'this'.
 
private TextBox txtBox1;

I assume this is defining a textbox with the name txtBox1?

You're exactly right.

Private TextBox txtBox1
Access level Class 'variable'/object name

Further to Fez's points about the this keyword it also used when you are referring to variables with the same name in methods as ones previously declared.


Using books such as 'Sam's Teach Yourself' is useful for concepts such as member access, the basics of OOP and good pratice when it comes to error handling but they will not teach you how to make anything. Other than the examples in the books that is!

I echo the previous sentiments - choose something you would like to make, or that you think you could use, and work towards it. As you stumble your way towards your goal you'll pick up far more than you would reading a book over and over.
 
This is just more evidence as to why this range of books should be barred from sale :/

Yup would have to agree with you there. A few years ago I tried the teach yourself ASP (was classic asp btw) in 24 hours, as means of a crash course - you soon realise it's impossible to learn something like that in 24 hours :) While it was a good introduction I felt there was little explanation to the code (E.g. this block of code does xxxxx).

I wouldn't say it should be banned from sale ( :) ) though, even if the title is very misleading.

Lately I've found O'Reily books are quite good E.g. a bought myself a copy of the PHP cookbook for a reference and found this explains things a lot clearer in in more detail.

But (imo, of course), I still think if you want to actually understand something beyond a book and use it in a real project, you should take on some practical examples. You could follow some web tutorials for example. In all honestly I leant the most in my first web development job a couple of years ago, where I took home several big sites coded by a more experienced developer.
 
Last edited:
A combination of the two is what works best for me.

Jumping straight into a project doesnt give you a general understanding or initial grounding in the subject.

I think you are going about it the right way. Keep progressing with the book, but think about something you may want to build too. That way you can keep learning once you have the grounding the book will give.
 
I find that the best approach is not to learn directly from a book, but just to have some good reference material. Learning by doing is by far and away the best way.
 
Books have their place and I know I've certainly learned a great deal from reading programming books.
I prefer reference books than the tutorial style ones of the type referred to here though.

Personally I would jump in and try and put together a small project myself and then refer to books if there's something I'm not sure about or an area on which I want more information.

I definitely wouldn't say that completely self taught is the right approach as then you'd learn nothing about proper practices and style etc.
 
Back
Top Bottom