Intro to C# Coding
Date: Monday, January 6th
Description: Course introduction, setting up applications we’ll be using, learning about C# basics
About: Visual Studio
What
Free, integrated development environment (IDE)
Key Features
Coding & debugging
Project templates for application development
Integrated (built-in) tools (e.g. GIT, testing tools, diagnostics)
Optional extensions for customizing & enhancing functionality
Cross-platform development (meaning apps created on VS can be used on diff machine types)
Ideal Use Cases
Learning a new programming language
Building small to medium-scale applications
.NET Platform
Free, open-source, development platform that facilitates cross-platform development
Supports the use of tools like…
Visual Studio
Visual Studio Code
Creating several different types of software:
Web apps
Web services
Desktop apps
Mobile apps
Cloud apps
Cloud services
Microservices
What is the C# Programming Language?
Statically-typed
Pure object-oriented programming language
runs on .NET framework
Similar to Java & C++
Use to build several diff types of software:
Business applications for storing & analyzing data
Dynamic web applications that can be accessed from a web browser
Games (2D & 3D)
Financial & scientific applications
Cloud-based applications
Mobile applications
First Code in C#
Console.WriteLine("Hello World!");Reading Error Messages in C#
#INPUT
console.WriteLine("Hello World!");#OUTPUT
(1,1): error CS0103: The name 'console' does not exist in the current contextconsoleshould be capitalized (C# is case-sensitive)(1,1) in error message suggests likely location of error
(line, character)
in this case —> error is at line 1, character 1
Common Mistakes New C# Programmers Make
Entering lower-case letters instead of capitalizing
CinConsole, or the lettersWorLinWriteLine.Entering a comma instead of a period between
ConsoleandWriteLine.Forgetting to use double-quotation marks, or using single-quotation marks to surround the phrase
Hello World!.Forgetting a semi-colon at the end of the command.
How to Make Comments in C#
To make a single-line comment:
Add
//at beginning of the line of code
To make a multiline comment:
Add
*/or/*at beginning of the line of code
Example:
// This line of code is a comment
Console.WriteLine("This is not a comment"); /* This is another comment Difference b/w Console.Write & Console.WriteLine
Console.Write()
prints a message without adding a new line at the end
any subsequent output will appear on the same line
Example
Console.Write("Hello");
Console.Write(" World!");Output
Hello World!Console.Write()
prints a message and automatically adds a new line at the end
any subsequent output will appear on the next line
Example
Console.WriteLine("Hello");
Console.WriteLine("World!");Output
Hello
World!