<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C# on Groundhog Learning</title><link>https://groundhoglearning.com/vault/programming/csharp/</link><description>Recent content in C# on Groundhog Learning</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://groundhoglearning.com/vault/programming/csharp/index.xml" rel="self" type="application/rss+xml"/><item><title>Comment (C#)</title><link>https://groundhoglearning.com/vault/programming/csharp/comment/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://groundhoglearning.com/vault/programming/csharp/comment/</guid><description>&lt;h2 id="single-line-comment"&gt;Single Line Comment&lt;a class="anchor" href="#single-line-comment"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A single line comment starts with &lt;code&gt;//&lt;/code&gt; and continues until the end of the line.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Everything on this line is commented.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Console.WriteLine(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello, World!&amp;#34;&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also write it inline, to the right of your code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Console.WriteLine(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello, World!&amp;#34;&lt;/span&gt;); &lt;span style="color:#75715e"&gt;// Everything to the right is commented.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="block-comment"&gt;Block Comment&lt;a class="anchor" href="#block-comment"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A block comment starts with &lt;code&gt;/*&lt;/code&gt; and ends with &lt;code&gt;*/&lt;/code&gt;. Everything in between is ignored.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;/*
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;This is a block comment
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;It can span
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;multiple lines
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;*/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Console.WriteLine(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello, World!&amp;#34;&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also use block comments in a single line or inline:&lt;/p&gt;</description></item><item><title>Create a C# Project in Visual Studio Code</title><link>https://groundhoglearning.com/vault/programming/csharp/create-project-vscode/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://groundhoglearning.com/vault/programming/csharp/create-project-vscode/</guid><description>&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"&gt;
 &lt;iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/Q-YRnMkDqcQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"&gt;&lt;/iframe&gt;
 &lt;/div&gt;

&lt;p&gt;In this tutorial, you will create a simple C# project in Visual Studio Code using the C# Dev Kit extension.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="step-by-step-instructions"&gt;Step-by-Step Instructions&lt;a class="anchor" href="#step-by-step-instructions"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://code.visualstudio.com/"class="book-link book-link--external" target="_blank" rel="noopener noreferrer" &gt;
 Download and Install Visual Studio Code&lt;span class="book-link__icon" aria-hidden="true"&gt;↗&lt;/span&gt;
 &lt;span class="sr-only"&gt;(external link)&lt;/span&gt;&lt;/a&gt; if you have not done so already.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Visual Studio Code&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit"class="book-link book-link--external" target="_blank" rel="noopener noreferrer" &gt;
 C# Dev Kit&lt;span class="book-link__icon" aria-hidden="true"&gt;↗&lt;/span&gt;
 &lt;span class="sr-only"&gt;(external link)&lt;/span&gt;&lt;/a&gt; extension.
&lt;ul&gt;
&lt;li&gt;Open the &lt;strong&gt;Extensions&lt;/strong&gt; panel on the left sidebar.&lt;/li&gt;
&lt;li&gt;Search for &lt;strong&gt;C# Dev Kit&lt;/strong&gt; and click &lt;strong&gt;Install&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;File Explorer&lt;/strong&gt; panel.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Open Folder&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose an existing folder or create a new one for your project.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;Command Palette&lt;/strong&gt; by pressing &lt;code&gt;Ctrl+Shift+P&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run the command &lt;code&gt;.NET: New Project...&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select a project template, for example: &lt;strong&gt;Console App&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter the &lt;strong&gt;project name&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Press &lt;strong&gt;Enter&lt;/strong&gt; to create the project in the selected folder.&lt;/li&gt;
&lt;li&gt;Select the solution file format: &lt;code&gt;.sln&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Press &lt;strong&gt;Enter&lt;/strong&gt; to create the project.&lt;/li&gt;
&lt;li&gt;Open the file &lt;code&gt;Program.cs&lt;/code&gt; file to start coding.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After completing these steps, your project folder will contain:&lt;/p&gt;</description></item><item><title>Declare a Variable in C#</title><link>https://groundhoglearning.com/vault/programming/csharp/declare-variable/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://groundhoglearning.com/vault/programming/csharp/declare-variable/</guid><description>&lt;p&gt;To declare a variable in C#, you write the &lt;strong&gt;type&lt;/strong&gt;, followed by the &lt;strong&gt;name&lt;/strong&gt;, followed by &lt;code&gt;=&lt;/code&gt; and the &lt;strong&gt;initial value&lt;/strong&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;string&lt;/span&gt; choice = &lt;span style="color:#e6db74"&gt;&amp;#34;1&amp;#34;&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;string&lt;/code&gt; — the type of value the variable will hold&lt;/li&gt;
&lt;li&gt;&lt;code&gt;choice&lt;/code&gt; — the name you use to refer to this variable&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;quot;1&amp;quot;&lt;/code&gt; — the initial value assigned to it&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="type-inference-with-var"&gt;Type Inference with &lt;code&gt;var&lt;/code&gt;&lt;a class="anchor" href="#type-inference-with-var"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Instead of writing the type explicitly, you can use &lt;code&gt;var&lt;/code&gt; and let the compiler figure it out:&lt;/p&gt;</description></item><item><title>Run a C# Project in Visual Studio Code</title><link>https://groundhoglearning.com/vault/programming/csharp/run-project-vscode/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://groundhoglearning.com/vault/programming/csharp/run-project-vscode/</guid><description>&lt;div class="reveal-container"&gt;
 &lt;iframe src="https://slides.com/groundhoglearning/run-csharp-project-vscode/embed" title="" loading="lazy" allowfullscreen&gt;
 &lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;In this tutorial, you will learn how to run a C# console program in Visual Studio Code.&lt;/p&gt;
&lt;h2 id="step-by-step-instructions"&gt;Step-by-Step Instructions&lt;a class="anchor" href="#step-by-step-instructions"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="option-1-using-the-play-button"&gt;Option 1. Using the Play Button&lt;a class="anchor" href="#option-1-using-the-play-button"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Visual Studio Code&lt;/strong&gt; and open the folder containing your project.&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;main program file&lt;/strong&gt;, usually &lt;code&gt;Program.cs&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;play button&lt;/strong&gt; at the top-right corner.&lt;/li&gt;
&lt;li&gt;VS Code will build and run the program, and the &lt;strong&gt;Terminal panel&lt;/strong&gt; will open automatically, showing the output.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote class='book-hint warning'&gt;
&lt;p&gt;Make sure you &lt;strong&gt;save your changes&lt;/strong&gt; (File -&amp;gt; Save or &lt;code&gt;Ctrl + S&lt;/code&gt;) to run the latest version of your program.&lt;/p&gt;</description></item></channel></rss>