- .NET Standard 2.0 Cookbook
- Fiqri Ismail
- 237字
- 2021-06-25 22:11:29
How to do it...
- Open Visual Studio 2017.
- Click File | New | Project and, in the New Project template dialog box, select Visual C# in the left-hand pane and Console App (.NET Framework) in the right-hand pane:

- In the Name: text box, type a name for your application. In this case, type HelloCSharp. Select a preferred location in the Location: drop-down list or click the Browse... button and select a location. Leave the defaults as they are:

- Now Click OK.
- You will be presented with a default code template for a C# console application. Let's hit F5 to give it a test run. If everything is fine, a console will pop up and close.
- At the end of the Main method, type the following code snippet:
private static string SayHello(string yourName)
{
return $"Hello, {yourName}";
}
- Now, inside your Main method, type the code that calls the previous method we just created:
var message = SayHello("Fiqri Ismail");
Console.WriteLine(message);
Console.ReadLine();
- Now we have written our first C# code. The code of the console app should look like the following after you are done coding:
static void Main(string[] args)
{
var message = SayHello("Fiqri Ismail");
Console.WriteLine(message);
Console.ReadLine();
}
private static string SayHello(string yourName)
{
return $"Hello, {yourName}";
}
- Let's hit F5 and test the application. If everything is OK, you should see the following screen. Press Enter to exit:

推薦閱讀
- jQuery Mobile Web Development Essentials(Third Edition)
- ExtGWT Rich Internet Application Cookbook
- 微信公眾平臺與小程序開發:從零搭建整套系統
- Machine Learning with R Cookbook(Second Edition)
- JMeter 性能測試實戰(第2版)
- 神經網絡編程實戰:Java語言實現(原書第2版)
- Instant Typeahead.js
- Swift 3 New Features
- Mastering Swift 2
- C語言程序設計上機指導與習題解答(第2版)
- Distributed Computing in Java 9
- 大學計算機基礎實驗指導
- Mastering Bootstrap 4
- Moodle 3.x Developer's Guide
- Scala編程(第4版)