🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C# Workshop - Week 4 (Ch. 11, 13, 14, & 15)

Started by
1 comment, last by JWalsh 16 years, 11 months ago

Welcome to the GDNet C# Workshop – .NET Book Zero Ch. 11, 13, 14, & 15

For a complete introduction to this workshop, please look here. Workshop Overview This workshop is designed to aid people in their journey to learn beginning C# (C-Sharp). This workshop is targeted at highly motivated individuals who are interested in learning C# or who have attempted to learn C# in the past, but found that without sufficient support and mentoring they were unable to connect all the pieces of this highly complex but powerful programming language. This is a 'guided' self-teaching C# workshop. Each student is responsible for taking the time to read the material and learn the information. Additionally, this workshop does not attempt to defend C# as a language, nor does it attempt to demonstrate that C# is either more or less useful then other programming languages for any particular purpose. People who intend to start a discussion about the differences between C# and ANY other languages (except as are relevant to a particular discussion), are encouraged to do so elsewhere. This workshop is for educational, not philosophical discussions. Finally, the community and tutors that arise out of this workshop are here for making the learning process run more smoothly, but are not obligated to baby-sit a person's progress. Because everyone will be working from the same references (.NET Book Zero and optionally the C# Language Specification 1.2 & 2.0), students may find it easier to get answers to the specific questions they might have. There is no minimum age requirement, and there is no previous programming experience required. However, we will be moving quickly so it's essential that students stay on task and dont fall behind. Experienced C# Programmers Feel free to post your own additional knowledge about the topics, however please try and keep the information you provide objective. If you MUST provide subjective/opinion-based information, please do so by marking the paragraph with [opinion] tags. This will make it clear to the readers what is fact, and what is opinion. Also, it may be relevant to mark some information with [observation] tags for information which you’ve “observed” but may not be fact. Finally, if you’re providing information which is related to common programming errors, you might tag it with a [warning] tag. Also, feel free to post links to additional resources about the topics for this week. I will do my best to add those to the “Additional Resources” section at the bottom of this post. Quizzes & Exercises Each week I will post 'quiz' questions and exercises in the weekly thread. Please try and answer them by yourself. Once you've done so, feel free to look over the answers provided by others and submit your own answers if you've not yet seen them posted. Discussion about the quiz questions and answers is encouraged for clarification. Finally, experienced C# programmers may feel free to post quiz-like questions and exercises of their own.

.NET Book Zero Chapters 11, 13, 14, and 15

Introduction Welcome to week 4 of the C# Workshop. This week we get into the real heart of the C# language as we explore user-defined types more closely. In chapter 11 we take a look at methods and fields. As we’ve not yet covered allocation of objects, this chapter deals entirely with static methods and fields – which are members associated with the class or struct, and not with a particular instance of a struct or class. In addition to a general lesson on static fields and methods, Petzold also briefly describes the use of the const (implicitly static) and readonly keywords as they might be applied to member fields. After he focuses on fields for a while he turns his attention back to methods. He briefly talks about method overloading, parameter passing, value vs. reference types, the out and ref keywords, and the use of arrays as parameters, both with and without the ‘param’ keyword. By the end of chapter 11 you should have a reasonable understanding of how static fields are created and how methods are used to perform blocks of code which may need to be executed in multiple locations within your program. After his chapter on members and fields we finally get to classes, structs, and objects. Here he spends a full chapter on the differences between classes and structs, how they’re created, and how they are used. This is a short chapter and in a lot of ways is just a precursor to chapter 14. In chapter 14 we took what we learned in the previous chapter and we move on to instance members, fields, and instances of classes and structs themselves. The Date class which is made in chapter 13 is brought more in line with standard Object Oriented practices - as he makes the methods instance-based, uses static fields and members in a smarter fashion, and uses a bit of inheritance with the virtual and override keywords to create a custom ToString method, present in all system and user defined types. And Finally, with the ability to create structs, classes, and objects with fields and methods, we learn the correct way to put structs and classes into a stable starting state. Specifically, member field declarations (only available on classes) and also constructors. Looking back at what we’ve covered so far. By the end of this chapter you will have learned how to work with strings and the console. You were introduced to the standard simple data types, what types of data they use, and what their valid ranges are. Next you learned about operators and expressions; branching/selection - using if, else, and switch statements; and iteration via for, while, do-while, and foreach. Then, in this week you learned about classes, structures, methods, fields, and object. So by the end of this week you will have learned roughly 65% of the C# language, and in terms of what you’ll use most, probably 80. For informational purposes, You’ve now learned roughly 90% of what C programmers had at their disposal, though they did much of it a different way. Everything you’ll learn from this point out is unique to object oriented programming languages like C++ and C#. And save for operator overloading and generics (aka templates), almost everything we’ll learn from this point out is unique to C#. Additional Resources None...

Good Luck!

[Edited by - JWalsh on July 29, 2007 2:30:53 PM]
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints
Advertisement
Has chapter 12 been deliberately missed out for this week?
How about them apples?
Yes. Chapter 12 is on Exception Handling. I felt it wasn't as important as covering 13-15 this week. I wanted to make sure those chapters got covered in plenty of time for people to complete their projects.

But dont worry, we'll return to chapter 12 next week.

Cheers!
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

This topic is closed to new replies.

Advertisement