DlBreda
DlBreda

Reputation: 77

System in a consolewriteline

I was studying for my test today and I came accross the sentence System.Console.WriteLine();

Could some one tell me what the System stands for cause when I remove it i dont see any diffrence.

Upvotes: 1

Views: 76

Answers (6)

VisualBean
VisualBean

Reputation: 5008

Just the namespace where Console.WriteLine() resides which is a default import (using system)

Upvotes: 1

Red_4life
Red_4life

Reputation: 11

The System in System.Console.WriteLine() refers to the System namespace. Therefore, if you're importing System in your code, it's redundant to call the WriteLine method using that namespace.

http://msdn.microsoft.com/en-us/library/System(v=vs.110).aspx

Upvotes: 1

Ali Baghdadi
Ali Baghdadi

Reputation: 648

System refers to the main library that contains the fundamental classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. And Console type is one of them. the reason why you are not getting a difference is that it's referenced by default in the top of your class page

Upvotes: 1

nvoigt
nvoigt

Reputation: 77304

The System is the name of the namespace the class Console resides in. You need to give the full name or it won't compile. With one exception: if you have a line using System; on top of your file, whenever something cannot be found, a namespace of System will be assumed for lookup.

Upvotes: 1

Chris Shao
Chris Shao

Reputation: 8231

System is a Namespace. You will find it in the head of your code.

using System;

If you remove using System;, you will find Console.WriteLine(); can't be complied.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1500873

System is just the namespace which contains the Console type.

You almost certainly have a using directive like this in your code:

using System;

That imports every type within the namespace, so you can refer to it by its simple name. Without that directive, you would see a difference - System.Console would still work, but just Console wouldn't, because the compiler wouldn't know which type you meant.

Upvotes: 4

Related Questions