A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://dotnet.microsoft.com/learn/dotnet/in-browser-tutorial/1 below:

.NET In-Browser Tutorial - Step 1: Intro

Step 1: Intro

This is a .NET console application written in C#. Select Run code to try it out.

Console.WriteLine("Hello World!");
Step 2: Strings

Try modifying the code so that the console says hello to your name, instead of the world (for example, Hello Ana!). Select Run code to see if you got it right.

Console.WriteLine("Hello <name>!");
Step 3: Variables

Variables hold values that you can use elsewhere in your code.

Let's store your name in a name variable, then read the value from that variable when creating the output message.

                    var name = "<name>";
Console.WriteLine("Hello " + name + "!");
                    Show me
                
                    var name = "<name>";
Console.WriteLine("Hello " + name + "!");
                
Step 4: String interpolation

String interpolation lets you piece together strings in a more concise and readable way.

If you add a $ before the opening quotes of the string, you can then include string values, like the name variable, inside the string in curly brackets. Try it out and select Run code.

                    var name = "<name>";
Console.WriteLine($"Hello {name}!");
                    Show me
                
                    var name = "<name>";
Console.WriteLine($"Hello {name}!");
                
Step 5: Methods

Methods take inputs, do some work, and sometimes return a result.

ToUpper() is a method you can invoke on a string, like the name variable. It will return the same string, converted to uppercase.

Update the greeting to change the name of the person being greeted to uppercase and select Run code.

                    var name = "<name>";
Console.WriteLine($"Hello {name.ToUpper()}!");
                    Show me
                
                    var name = "<name>";
Console.WriteLine($"Hello {name.ToUpper()}!");
                
Step 6: Collections

Collections hold multiple values of the same type.

Replace the name variable with a names variable that has a list of names. Then use a foreach loop to iterate over all the names and say hello to each person.

                    var names = new[] { "<name>", "Felipe", "Emillia" };
foreach (var name in names)
{
    Console.WriteLine($"Hello {name.ToUpper()}!");
}
                    Show me
                
                    var names = new[] { "<name>", "Felipe", "Emillia" };
foreach (var name in names)
{
    Console.WriteLine($"Hello {name.ToUpper()}!");
}
                

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4