Skip to content

Latest commit

 

History

History
181 lines (115 loc) · 6.68 KB

File metadata and controls

181 lines (115 loc) · 6.68 KB

Projeto em Português: Portugues

banner CSharp_Hello-World-with-CMD

Welcome | Hello World with CMD | Creating the File | Accessing the C# compiler | Compiling the code | Execution | Questions | Contacts | Developer

🤗 Welcome

Hello, welcome!

I had the idea to start the #100DaysOfCode challenge, in addition to sharing some projects for those interested in learning C#, so it's something very simple for those who would like to start programming or need to improve their skills.


Ana-Csharp CSharp - Hello World with CMD

📚 Take advantage of the code for this exercise

👩‍💻 Redo it your way

😉 If you have any questions, contact me


📝 Creating the File

  1. Create a folder on your computer to place the application.

  2. Create a new Text Document and name it without spaces in the title.

  3. Copy the following code into your txt file:

💬 Note: Use notepad to edit your file, you don't need an advanced text editor.
using System;

class Program
{
	static void Main(string[] args)
	{
		Console.WriteLine("Running Project 1 - Hello World:");
		
		Console.WriteLine("Olá mundo! Hello world!");
		Console.WriteLine("The run has ended.");
		Console.WriteLine("Press Enter to finish...");
		Console.ReadLine();
	}
}

📂 Accessing the C# compiler

  1. Use your computer's File Explorer to navigate through Windows directories to the Microsoft.NET Framework folder.
  • Path where the folder is usually located on the computer: C:\Windows\Microsoft.NET\Framework
  1. Open the version 4 folder that has the files used by the CLR (common language runtime).

Common Language Runtime (CLR) Overview
.NET provides a runtime environment, called the Common Language Runtime, that executes code and provides services that facilitate the development process.
To learn more about CLR, click here!

  1. In this folder you will find the csc.exe file, copy the path of this file
  • Example: c:\Windows\Microsoft.NET\Framework\v4.0.30219\csc.exe


    csc: C Sharp Compiler

    C# Compiler Options
    This section describes the options interpreted by the C# compiler.
    To know more about compiler, click here


👩‍💻 Compiling the code

  1. Press the "Windows" key.

  2. Type "cmd".

  3. Open Command Prompt.

  4. Type in the Prompt: cd "path of the folder where you saved the application" and press Enter.

  • Example: cd C:\Users\Fulano\Documents\FolderExercise
  1. Paste the path of csc.exe, leave a space, paste the name and extension of your application file and press Enter.
  • Example: c:\Windows\Microsoft.NET\Framework\v4.0.30219\csc.exe Exercise.txt
💬 Note: To confirm that it worked, go to your application's directory with the File Explorer to check if the executable of your code appeared: "Exercise.exe".

▶ Execution

  1. To execute with Prompt type the name of the file and press Enter.
  • Example: Exercise.exe
  • Ready! Now it will be possible to see the execution of your application, because the message that you typed in your code will appear in the Prompt.
C:\Users\Fulano\Documents\FolderExercise>c:\Windows\Microsoft.NET\Framework\v4.0.30219\csc.exe Exercise.txt
Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240


C:\Users\Fulano\Documents\FolderExercise>Exercise.exe
Hello World!
💬 Note: If you edit this code, you will need to compile and run it again:
- c:\Windows\Microsoft.NET\Framework\v4.0.30219\csc.exe Exercise.txt
- Exercise.exe
‼ Note 2: Always follow the syntax rules of the language - C# is case sensitive, we must pay attention when writing keywords / reserved words, as some of them must start with capital letters, others with capital letters, and all must be written in exact and correct way for applications to work.

❓ Questions

Any questions, interact here:

  • Make questions
  • Give suggestions for improvement to the project
  • Share your ideas
  • And interact on the subject

😉 Remember this is a community we build together 💪.


✉️ Contacts

If you need help, contact me 😉

Gmail LinkedIn Beacons



🙋‍♀️ Developer

Ana Valentim

✏️ Created with ❤️ e C# by Ana Valentim.

💙 If you liked this project, give it a ⭐ and share!



⬆ Back to Top

Pixel-Art