Hello World!
Hello World!
//
convert the rest of the line to a comment./*
and */
characters. This is shown in the following example.Main
method, in which control starts and ends. The Main
method is where you create objects and execute other methods.Main
method is a static method that resides inside a class or a struct. In the previous 'Hello World!' example, it resides in a class named Hello
. You can declare the Main
method in one of the following ways:void
.Main
method, args
, is a string
array that contains the command-line arguments used to invoke the program. Unlike in C++, the array does not include the name of the executable (exe) file.Main
method prevents the console window from closing before you have a chance to read the output when you run your program in debug mode, by pressing F5.System.Console.WriteLine('Hello World!');
uses the WriteLine method. This is one of the output methods of the Console class in the run-time library. It displays its string parameter on the standard output stream followed by a new line. Other Console methods are available for different input and output operations. If you include the using System;
directive at the beginning of the program, you can directly use the System classes and methods without fully qualifying them. For example, you can call Console.WriteLine
instead of System.Console.WriteLine
:Hello.cs
. C# source code files use the extension .cs
.Developer Command Prompt
, and then tap or choose Developer Command Prompt for VS 2017.Hello.cs
file.Hello.cs
.csc Hello.cs
Fl studio for apple.Hello.exe
is created.Hello
alert
) to a minimum so that you don’t spend time on them if you plan to concentrate on another environment (like Node.js). We’ll focus on JavaScript in the browser in the next part of the tutorial.'node my.js'
.<script>
tag.<script>
tag contains JavaScript code which is automatically executed when the browser processes the tag.<script>
tag has a few attributes that are rarely used nowadays but can still be found in old code:type
attribute: <script type=…>
type
. Usually it was type='text/javascript'
. It’s not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that’s an advanced topic; we’ll talk about modules in another part of the tutorial.language
attribute: <script language=…>
<script>
tags, like this:<script>
tag. Since browsers released in the last 15 years don’t have this issue, this kind of comment can help you identify really old code.src
attribute:/path/to/script.js
is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, src='script.js'
would mean a file 'script.js'
in the current folder.<script>
tag can’t have both the src
attribute and code inside.<script src='…'>
or a regular <script>
with code.<script>
tag to add JavaScript code to a page.type
and language
attributes are not required.<script src='path/to/script.js'></script>
.