Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrooks G
5,284 PointsWhat does "types" mean in the context of the video -- removing Namespaces before "types" (e.g. Random, Math, Console)?
Thus far, the only discussion of types we've had has been in the previous video, aptly titled "Types." I have a bit of experience with C, so I'm familiar with variables/data types -- the "Types" video is very clear to me.
In the context of this video, are Console/Math/Random considered to be custom data types of sorts, or is "type" a reference to local Namespaces? Or something else?
Thanks!
2 Answers
Steven Parker
231,268 PointsI think you were on the right track the first time. The "types" would not be the namespaces themselves, but the classes contained within them.
Brooks G
5,284 PointsThanks for the clarification.
I'm aware that nested classes is/are a thing. To my surprise, "Console" is a class rather than a namespace.
In the example, "System.Console.WriteLine," I'm assuming "WriteLine" is a class nested within the "Console" class? I know that "System" is the namespace here.
Brooks G
5,284 PointsNow that I think about it, along with the other example ("System.Math.Round"), WriteLine and Round are obviously methods rather than their own classes (in the other example, System being the namespace, and Math being a class within).
Scratch my previous question. New question: What's up with the difference in notation between .GetType and .WriteLine -- in that one typically precedes the method's argument and the other follows another's argument (I.e. WriteLine() vs. WriteLine().GetType)? I'd assume that it's something specific to GetType and related methods. Is there a reason that GetType doesn't typically precede arguments as well?
Thanks!
Brooks G
5,284 PointsActually, ignore that question, too -- another video explained that methods such as .GetType can only call on objects (and thus follow), whereas methods like WriteLine can be called by themselves (without objects). If there's any other distinctions worth knowing, I'd be more than interested to find out; otherwise, I think I've got it.
Cheers!
Steven Parker
231,268 PointsIt may have just been a case of "getting ahead of yourself".
Happy coding!
Brooks G
5,284 PointsIndeed it was (several times over at that!).
Marked it. Cheers!
Brooks G
5,284 PointsBrooks G
5,284 PointsI know classes/structs are considered to be complex Data Types of sorts. Perhaps it's just a reference to a specific class (Random, Math, Console) that's defined within one of the Namespaces we're qualifying with the using directive (e.g. "System" in the first example or "Microsoft.VisualStudio.TestTools.UnitTesting," which references several (nested) Namespaces)?