intro-to-dotnet-web-dev/2-csharp/README.md

70 lines
3.8 KiB
Markdown
Raw Normal View History

2022-04-29 00:20:11 +02:00
# C# Crash Course
2022-04-29 00:53:48 +02:00
In this C# Crash Course, we'll go over the basics of C# so that you'll be ready to build out exciting web apps in emails 3, 4, and 5! We'll start by going through the key attributes of C#, syntax basics, and introduce you to OOP. At the end, we'll link you to some quick in-browser C# challenges so you can apply these concepts.
2022-04-29 00:20:11 +02:00
## Topics you'll learn
* Language attributes
2022-04-29 20:52:27 +02:00
* Strongly typed
2022-04-29 00:20:11 +02:00
* Compiled languages
* Syntax basics
* Keywords
* Accessing methods
* Parameters
* Semicolons
* Data types
* Variables
* Arithmetic operators
* Booleans
* Object Oriented Programming
* Records
* Objects
* Properties
* Methods
2022-04-29 20:52:27 +02:00
# Let's get into it!
## Language Attributes
C# is a strongly typed, compiled, object oriented language. Let's break this down.
* In a **strongly typed** language, every variable has a defined type. Every method declaration specifies a name, the type and kind for each input parameter and for the return value.
* A **compiler** converts the code you write into a format that your computer can understand.After you write C# and build it, the C# compiler (called Roslyn) will analyze your code to check for any errors.
2022-04-29 00:20:11 +02:00
2022-04-29 20:52:27 +02:00
## Syntax Basics
Here's a piece of code that will print "Hello world!" to the console.
```csharp
using System;
Console.WriteLine("Hello world!");
```
### Keywords
With C#, you use **keywords** like *using* and *Console*.
>Keywords are predefined, reserved identifiers that have special meanings to the compiler.
### Accessing methods
The Dot in *Console.WriteLine* allows us to access methods and properties. In this example, **Console** is a type that represents the console window. **WriteLine** is a method of the Console type that prints a line of text to that text console.
### Parameters
...
## OOP
C# is an object-oriented language. You define types and their behavior.
...
# Mini Challenges!
2022-04-29 00:53:48 +02:00
Each of these mini challenges is designed so that you can apply C# concepts to mini coding exercises. These challenges are all sourced from Microsoft documentation and will allow you to get coding inside your browser. Easy peasy!
2022-04-29 00:20:11 +02:00
| # | Challenge | Solution | Duration | What you will learn | More information |
|-| ------------------------------- | ------------------------------- | ----------- | -------------------------------------- | - |
1 | [Hello World](https://docs.microsoft.com/learn/modules/csharp-write-first/2-exercise-hello-world/?ns-enrollment-type=learningpath&ns-enrollment-id=learn.languages.csharp-first-steps)| N/A | 3 min | case sensitive, strings, comments | [Intro to C# Tutorial](https://docs.microsoft.com/dotnet/csharp/tour-of-csharp/tutorials/hello-world?WT.mc_id=csharpnotebook-35129-website), [C# documentation](https://docs.microsoft.com/dotnet/csharp/) |
2 | [Variables](https://docs.microsoft.com/learn/modules/csharp-literals-variables/6-challenge )|[Solution](https://docs.microsoft.com/learn/modules/csharp-literals-variables/7-solution)| 5 min | variables, data types, strings, ints, decimals | [Numberic Types](https://docs.microsoft.com/dotnet/csharp/tour-of-csharp/tutorials/numbers-in-csharp?WT.mc_id=csharpnotebook-35129-website), [C# documentation](https://docs.microsoft.com/dotnet/csharp/) |
2022-04-29 00:53:48 +02:00
3 | [Challenge](...)|[Solution](...)| 5 min | topics | [Link](...) |
2022-04-29 20:52:27 +02:00
# Bonus and more ways to connect
2022-04-29 00:53:48 +02:00
Want more practice with C#? The .NET team has you covered. Here's a few learning resources:
* C# Video Series on [Microsoft Docs](https://docs.microsoft.com/shows/CSharp-101/?WT.mc_id=dotnet-35129-website) or [YouTube](https://www.youtube.com/watch?v=Z5JS36NlJiU)
* Self Guided Tutorials on [Microsoft Learn](https://docs.microsoft.com/users/dotnet/collections/yz26f8y64n7k07)
* [Learn to Code Page](https://dotnet.microsoft.com/learntocode)
Connect with us! Check out the [.NET Community Page](https://dotnet.microsoft.com/platform/community) to find links to our blogs, YouTube, Twitter, and more.