レッスン1:こんにちは、世界!


At the end of this lesson, you should be able to answer the following:

  • What is a statement?
  • How do I display a message on the screen using C#?

我々のプログラムにメッセージを印刷しましょう.こんにちは、世界を印刷するつもりですコンソールに.
コンソール(また、端末として知られています)は、我々がコンピュータと対話するのを可能にするテキストだけのディスプレイまたは環境です.

Did you know?

The "Hello, World!" program is the traditional first program for programming languages. It is often the first program written by people who are learning to code.


C言語をプログラムに印刷するには、コマンドを使いますConsole.WriteLine() .
あなたが表示したいメッセージは() . このように、二重引用符の中にメッセージを入れる必要があります."Hello, World!"ノートブックのコードボックスで次のように入力します.
Console.WriteLine("Hello, World!");
この命令の行を文と呼ぶ.プログラムは文から成り立っている.
文はセミコロンで終わる; ). 文のような文を考えてください.セミコロンは完全な停止または期間に相当します.
完全な停止がない場合は、読者(私たちのケースでは、Cの経典コンパイラ)は、我々の文章を開始し、終了するか分からないので、私たちを理解することが困難になります.
次に、コードボックスの[実行]ボタンをクリックしてプログラムを実行します.

プログラムの出力は、コードボックスの下部に表示されます.

おめでとう!あなたの最初のC経典プログラムを書いて実行します.
別のメッセージを表示しましょう.執筆I'm learning C#! コンソールに.
最初の後Console.WriteLine() , Enterキーを押して新しい行に移動し、次のステートメントを入力します.
Console.WriteLine("I'm learning C#!");
完全なプログラムは次のようになります.
Console.WriteLine("Hello, World!");
Console.WriteLine("I'm learning C#!");
実行ボタンをクリックして、再度プログラムを実行します.
出力は次のようになります.

ご承知の通り、ステートメントは順番に実行されます.あなたが置かれるならばI'm learning C#! 前にHello World! ステートメントの出力は異なります.

Tip

You may have notice a box popping up while typing. This feature is part of IntelliSense, a helpful tool for writing code. It provides hints, suggestions, and documentation for your code.



Question

What happens when you remove the semicolon from the end of the statements? Will the program run?


Console.WriteLine("Hello World")
Console.WriteLine("I'm learning C#!")

Question

Can you spot the error in this program? (If you're stuck, copy and paste this to the code box. The squiggly red lines will show you where the error is!)


Console.WriteLine(Hello World!);

Challenges

  1. Introduce yourself to the computer! Display the message Hi! My name is <NAME>. Replace <NAME> with your name, of course.
  2. Print out your favourite haiku (Japanese poem) on the console. If you don't have one, use one of the examples here. Each line of the haiku should be printed on its own line.