intro-to-dotnet-web-dev/2-csharp/README.md
2022-04-29 11:52:27 -07:00

3.8 KiB

C# Crash Course

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.

Topics you'll learn

  • Language attributes
    • Strongly typed
    • Compiled languages
  • Syntax basics
    • Keywords
    • Accessing methods
    • Parameters
    • Semicolons
    • Data types
    • Variables
    • Arithmetic operators
    • Booleans
  • Object Oriented Programming
    • Records
    • Objects
    • Properties
    • Methods

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.

Syntax Basics

Here's a piece of code that will print "Hello world!" to the console.

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!

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!

# Challenge Solution Duration What you will learn More information
1 Hello World N/A 3 min case sensitive, strings, comments Intro to C# Tutorial, C# documentation
2 Variables Solution 5 min variables, data types, strings, ints, decimals Numberic Types, C# documentation
3 Challenge Solution 5 min topics Link

Bonus and more ways to connect

Want more practice with C#? The .NET team has you covered. Here's a few learning resources:

Connect with us! Check out the .NET Community Page to find links to our blogs, YouTube, Twitter, and more.