Skip to content

Commit

Permalink
Converting C# Basics to use .NET Fiddle (#498)
Browse files Browse the repository at this point in the history
* Fixing statement on C#

updating to be more accurate

* Update write-to-console.md

Removing need for Main method - use top level statements.

* fix date

* Changing graphic to remove top level statements

* Update comments.md

Give them something to do on this page instead of just reading.

* fixing date

* Fixing grammar and examples

* Add heading

* Add Replit link

* Minor updates to operators lesson

* Adding Mac to where C# can run

* just types in control-structures

* fixing date

* clarity updates for methods

* cleaning up objects and classes

* Fixing typo

Co-authored-by: Oliver Zhang <[email protected]>

* Fixing grammar

Co-authored-by: Oliver Zhang <[email protected]>

* Removing extra spac

* fixing C# to csharp

* moving c# to csharp for code blocks

* formatting if, for, and while in intro paragraph

* Update and rename using-replit.md to using-netfiddle.md

started conversion

* Adding new graphic for .NET Fiddle

* Finishing the conversion for the Using page

* Adding .NET Fiddle screen captures

* Fixing a couple of misses

* Replacing replit on Print Statements page

* replacing replit on Comments page

* Replacing replit in variables page

* Replacing replit on Operators page

* fixing an embedded fiddle in variables

* replacing replit on control structures page

* replacing replit ion Methods page

* replacing replit on Classes page

* fixing typo

* Updating fiddle instructions

* Updating to fix the intro to Fiddle

* [Github Actions] Add AI translations

* Revert "[Github Actions] Add AI translations"

This reverts commit d9f4736.

---------

Co-authored-by: Oliver Zhang <[email protected]>
Co-authored-by: webreidi <[email protected]>
Co-authored-by: Oliver Zhang <[email protected]>
  • Loading branch information
4 people authored Sep 20, 2024
1 parent 8d60689 commit c1537de
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 79 deletions.
7 changes: 3 additions & 4 deletions content/english/csharp-basics/classes-and-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ public class Person{
## Try it Out 🐥!

Let's make a `Bird` class to represent Patrick 🐥 and all of his Bird friends by following the steps below!
**Note:** For this exercise, you will be working in Bird.cs instead of Main.cs.

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/JavaBasicsBird" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/OH5XQO" frameborder="0"></iframe>

### First, we start by defining the class name in the format `public` `class` `name`.

Expand Down Expand Up @@ -120,7 +119,7 @@ For example, to declare `species` as a private field of class `Bird`, you would

### Third, let's create the constructor for the class `Bird`.

Usually, constructor is the method that initialializes value to all the fields in a class. It has the format `public` `class name` `(parameter)`. Since we have 5 fields in this class, the constructor will take in 5 parameter/inputs.
Usually, constructor is the method that initializes value to all the fields in a class. It has the format `public` `class name` `(parameter)`. Since we have 5 fields in this class, the constructor will take in 5 parameter/inputs.

```csharp
public Bird(string speciesInput, string nameInput, string hobbyInput, int ageInput, bool loveMusicInput){
Expand Down Expand Up @@ -224,4 +223,4 @@ Next, let's call the `ToString()` method on these `Bird` objects we created to p

Try it out and print out all the information of the bird friends you created 🐦🐤🐔🐧!

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsClasses" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/fMXXuT" frameborder="0"></iframe>
4 changes: 2 additions & 2 deletions content/english/csharp-basics/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Also, adding comments will not affect the program whatsoever. So, you can add co

## Play with Comments

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsHelloWorld" target="_blank">Launch Replit</a>
In the .NET Fiddle frame below, add a single line comment and a multi-line comment to your program.

Add a single line comment and a multi-line comment to your program.
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/TTAhVm" frameborder="0"></iframe>

{{% notice tip %}}

Expand Down
4 changes: 2 additions & 2 deletions content/english/csharp-basics/control-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Patrick should say "Good Morning" between 0:00 - 11:59, "Good Afternoon" between
2. Fill out the correct `boolean expression A` and `boolean expression B` to complete the program.
3. Test your result by assigning the variable `currentHour` to numbers from 0 to 23:

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsControlStructures" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/T6AUdh" frameborder="0"></iframe>

## Repeat It Again: For-Loop, While-Loop

Expand Down Expand Up @@ -160,4 +160,4 @@ Console.WriteLine("Answer calculated in a while loop: " + total);

Test this out below by clicking `Run` and write a `for` loop version that calculates the same thing! You should get the same answer!

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsLoops" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/ySFwK0" frameborder="0"></iframe>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion content/english/csharp-basics/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ Once you solved the challenge, you will see the following message:
Congratulations! Challenge Solved!
```

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsMethods" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/ireaAA" frameborder="0"></iframe>
6 changes: 3 additions & 3 deletions content/english/csharp-basics/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The add (`+`) operator is used on Strings as a concatenation operator. For examp
### Instructions
1. Use the program below to practice using the arithmetic operators. Change the numbers to see the answers.

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsOperators" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/dUSTOt" frameborder="0"></iframe>

## Comparisons: Relational Operator

Expand Down Expand Up @@ -92,7 +92,7 @@ age == 3; // checks to see if the value of age is 3

1. Use the program below to practice using the comparison operators. Change the numbers to see the answers.

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsRelationalOperators" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/tZs8tb" frameborder="0"></iframe>

## Exam Statistics!

Expand Down Expand Up @@ -139,4 +139,4 @@ Let's write it with the help of operators 🎵!

{{% /notice %}}

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsOperatorPractice" target="_blank">Launch Replit</a>
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/mM7xbj" frameborder="0"></iframe>
39 changes: 39 additions & 0 deletions content/english/csharp-basics/using-netfiddle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "Using .NET Fiddle"
date: 2024-09-17T00:00:00Z
weight: 1
draft: false
---

### Using .NET Fiddle
Today you will be using .NET Fiddle to learn how to code in C#.

Before we start, let's first understand how the window works. On the left side you have a list of options. These have all been set for you, so you do not need to worry about those. The center of the screen contains code, or instructions for the computer to run. By pressing the **run** button (the button with the triangle in the middle at the top of the frame), you tell the computer to perform the instructions in the code. The results from running the code will be displayed on the bottom of the screen.

<img src="../images/donetfiddle-overview.png" height="300" alt=".NET Fiddle Window Layout" />

Spend some time and get to know the tool below.

<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/ccWNBp" frameborder="0"></iframe>

### Some tips on C#

A few important tips:
1. Each line of code ends with a semicolon `;`
2. There will be code in the examples that you don't understand. That is ok, ignore for now and focus on the task you are working on.

## Saving your work

If you want to save your work throughout these exercises, you will need to sign up for a .NET Fiddle account, if you do not yet have one.

Click the button below to sign up for a .NET Fiddle account - you will need an email account in order to sign up. If you already have a .NET Fiddle account, you can login to your account using the below button as well.

<a class="my-2 mx-4 btn btn-info" href="https://dotnetfiddle.net/SignUp" target="_blank">Sign up for .NET Fiddle</a>

<img src="../images/dotnetfiddle-signup.png" height="300" alt=".NET Fiddle sign up form" />

Then, you can now *fork* the Fiddle, which simply means to make a copy of the program, so that we can make and save our own changes to it. Click on the "Fork" button on the top.

After forking the Fiddle, you will see a window similar to the one below:

<img src="../images/dotnetfiddle-window.png" height="300" alt=".NET Fiddle window" />
53 changes: 0 additions & 53 deletions content/english/csharp-basics/using-replit.md

This file was deleted.

13 changes: 6 additions & 7 deletions content/english/csharp-basics/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ The last varable is an interesting one. It can only have a value of `true` or `

## Play with variables

Let's see what we can do with variables. Launch and fork the repl.
Let's see what we can do with variables.

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsVariables" target="_blank">Launch Replit</a>

Try entering these lines and **run**:
In the .NET Fiddle Frame below, fork the Fiddle and try entering these lines and **run**:

```C#
int age = 10;
Expand All @@ -68,9 +66,10 @@ Console.WriteLine(age); // prints out 12
```
We can assign a value to a varable, reference it and then change the value.

## What the Type -- Help Patrick!
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/PPCCzG" frameborder="0"></iframe>

Patrick 🐥 isn't a master of data types! He often mixed them up when declaring variables. Let's help him fix his mistakes.
## What the Type -- Help Patrick!

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsDataTypes" target="_blank">Launch Replit</a>
Patrick 🐥 isn't a master of data types! He often mixed them up when declaring variables. Let's help him fix his mistakes in the .NET Fiddle below.

<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/xKMKvn" frameborder="0"></iframe>
12 changes: 5 additions & 7 deletions content/english/csharp-basics/write-to-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ Our first excercise is to get comfortable with the structure of a simple C# appl

Let’s try to run a C# program that prints `Hello World` to the console. The line of code `Console.WriteLine ("Hello World");` does this for us. It tells the computer to write whatever is inbetween the () to the screen.

Launch the repl and fork it. Give it a try by pressing the **run** button. The output will appear on the right.

<a class="my-2 mx-4 btn btn-info" href="https://replit.com/@nuevofoundation/CSharpBasicsHelloWorld" target="_blank">Launch Replit</a>

### Let's write some code!

Add a new line of code below the first line to print "Hello *your name*". It should look something like this.
<iframe width="100%" height="475" src="https://dotnetfiddle.net/Widget/0g4Vu7" frameborder="0"></iframe>

In the above .NET Fiddle frame, add a new line of code below the first line to print "Hello *your name*". It should look something like this.

<img src="../images/Step1.png" height="300" alt="The starting screen of a repl" />
<img src="../images/Step1.png" height="300" alt="The starting screen of a fiddle" />

You should see your output on the right side of the screen. Cool huh?
You should see your output on the bottom of the screen. Cool huh?

Let's try printing other things. Add some additional lines of code to:
1. Print numbers by putting numbers in the parenthesis (i.e. `Console.WriteLine(42);`). No double quotes needed.
Expand Down

0 comments on commit c1537de

Please sign in to comment.