using namespace ....
Hey, so I was given a gift of visual studio 2010 Game Studio 4.0 and a yr membership with Xbox indie (for submitting games), and I sighed as I was really happy to dev for my 360 for my first time ever I am also having to leant a new language a new compiler and a new framework. It all seems pretty straightforward and the documentation for game studio is better than I expected, but I was in the habit of breaking most of my programs into sperate headers to keep things organized but with c# it seems to be a little different. I am trying to peice this together and I am sure after only a few days i may seem rwtarded, but is the using namespace randomnamspace. The new way to do #includes? Like if I wanted to break a game down into different files could I just add new .cs to the project define a namespace in it then just put using thatnamepsace at the top of my main page? What are common pitfalls or probelms I should avoid with learning this new method?
Thanks in advance for any info.. also I will be buying a book on it soon if anyone has any suggestions (I don't want a beginner book with a lot of "fluff")
Namespaces are entirely different than #includes. Adding "using <namespace>;" to a file just prevents you from having to use the FQN of types that reside in that namespace. For instance, if you didn't have "using System.Collections.Generic;", you'd have to type:
System.Collections.Generic.List<int> listOfIntegers = new System.Collections.Generic.List<int>();
So not including the "using" doesn't prevent you from using types in that namespace, it just provides a shortcut way of identifying types in your code.
List<int> listOfIntegers = new List<int>();
You're definitely still free to break your code up into different .cs files, but generally the namespace will be the same and you'll break your program out into different classes. For instance, you're going to add a GameObject class, you'd right-click your project, select Add -> New Class, type in GameObject.cs and then the IDE will create the new file along with some standard usings, a namespace structured after the project/file heirarchy, and a stub for the class itself.
Ok so all the "include" stuff is now managed by the ide or the language then?
Yes, sort of. By default Visual Studio includes references to the most common set of objects, but you may have to add references (right click on references in solution explorer) to some of the DLLs. Once you add a reference to a DLL, any object in that DLL is available (public object, that is) for you to use.
As for books, I'd go with the O'Reilly books, specifically C# 4.0 in a Nutshell, 4th Edition..-..O'Reilly Media