Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting C# Basics to use .NET Fiddle #498

Merged
merged 40 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
887f3f9
Fixing statement on C#
webreidi Sep 16, 2024
ef261fb
Update write-to-console.md
webreidi Sep 16, 2024
acfcca7
fix date
webreidi Sep 16, 2024
4e8f859
Changing graphic to remove top level statements
webreidi Sep 16, 2024
3dfdd4c
Update comments.md
webreidi Sep 16, 2024
7c0aa44
fixing date
webreidi Sep 16, 2024
8f9e2b6
Fixing grammar and examples
webreidi Sep 16, 2024
d43689d
Add heading
webreidi Sep 16, 2024
34f23c6
Add Replit link
webreidi Sep 16, 2024
74bbb8b
Minor updates to operators lesson
webreidi Sep 16, 2024
f25dbec
Adding Mac to where C# can run
webreidi Sep 16, 2024
ebb7202
just types in control-structures
webreidi Sep 17, 2024
f7cd502
fixing date
webreidi Sep 17, 2024
fd22f7e
clarity updates for methods
webreidi Sep 17, 2024
72b0415
cleaning up objects and classes
webreidi Sep 17, 2024
b0f3f8f
Fixing typo
webreidi Sep 17, 2024
9bbfcb5
Fixing grammar
webreidi Sep 17, 2024
0b7d4bf
Removing extra spac
webreidi Sep 17, 2024
ba5692e
fixing C# to csharp
webreidi Sep 17, 2024
f020914
moving c# to csharp for code blocks
webreidi Sep 17, 2024
ba29a60
formatting if, for, and while in intro paragraph
webreidi Sep 17, 2024
d29edac
Update and rename using-replit.md to using-netfiddle.md
webreidi Sep 17, 2024
7857327
Adding new graphic for .NET Fiddle
webreidi Sep 17, 2024
1da6580
Finishing the conversion for the Using page
webreidi Sep 17, 2024
3609627
Adding .NET Fiddle screen captures
webreidi Sep 17, 2024
50e2957
Fixing a couple of misses
webreidi Sep 18, 2024
fc1abec
Replacing replit on Print Statements page
webreidi Sep 18, 2024
e91279c
replacing replit on Comments page
webreidi Sep 18, 2024
43247ed
Replacing replit in variables page
webreidi Sep 18, 2024
e6334af
Replacing replit on Operators page
webreidi Sep 18, 2024
af0e118
fixing an embedded fiddle in variables
webreidi Sep 18, 2024
ae5e00c
replacing replit on control structures page
webreidi Sep 18, 2024
98f8f59
replacing replit ion Methods page
webreidi Sep 18, 2024
1598c00
replacing replit on Classes page
webreidi Sep 18, 2024
4045c10
fixing typo
webreidi Sep 18, 2024
b61191c
Updating fiddle instructions
webreidi Sep 18, 2024
8a9dbb2
Updating to fix the intro to Fiddle
webreidi Sep 19, 2024
2af112b
Merge branch 'master' into webreidi-csharpBasicsConversionToFiddle
webreidi Sep 19, 2024
d9f4736
[Github Actions] Add AI translations
webreidi Sep 19, 2024
c818301
Revert "[Github Actions] Add AI translations"
Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

webreidi marked this conversation as resolved.
Show resolved Hide resolved
<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.

webreidi marked this conversation as resolved.
Show resolved Hide resolved
## 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
Loading