Tutorials
References
Exercises
Videos
Menu
Log in
Free Website
Get Certified
Pro
HTML
CSS
JAVASCRIPT
SQL
PYTHON
PHP
BOOTSTRAP
HOW TO
W3.CSS
JAVA
JQUERY
C
C++
C#
R
React
Dark mode
Dark code
×
Tutorials
HTML and CSS
Learn HTML
Learn CSS
Learn RWD
Learn Bootstrap
Learn W3.CSS
Learn Colors
Learn Icons
Learn Graphics
Learn SVG
Learn Canvas
Learn How To
Learn Sass
Data Analytics
Learn AI
Learn Machine Learning
Learn Data Science
Learn NumPy
Learn Pandas
Learn SciPy
Learn Matplotlib
Learn Statistics
Learn Excel
XML Tutorials
Learn XML
Learn XML AJAX
Learn XML DOM
Learn XML DTD
Learn XML Schema
Learn XSLT
Learn XPath
Learn XQuery
JavaScript
Learn JavaScript
Learn jQuery
Learn React
Learn AngularJS
Learn JSON
Learn AJAX
Learn AppML
Learn W3.JS
Programming
Learn Python
Learn Java
Learn C
Learn C++
Learn C#
Learn R
Learn Kotlin
Learn Go
Learn Django
Learn TypeScript
Server Side
Learn SQL
Learn MySQL
Learn PHP
Learn ASP
Learn Node.js
Learn Raspberry Pi
Learn Git
Learn AWS Cloud
Web Building
Create a Website
NEW
Where To Start
Web Templates
Web Statistics
Web Certificates
Web Development
Code Editor
Test Your Typing Speed
Play a Code Game
Cyber Security
Accessibility
Blog
Data Analytics
Learn AI
Learn Machine Learning
Learn Data Science
Learn NumPy
Learn Pandas
Learn SciPy
Learn Matplotlib
Learn Statistics
Learn Excel
Learn Google Sheets
XML Tutorials
Learn XML
Learn XML AJAX
Learn XML DOM
Learn XML DTD
Learn XML Schema
Learn XSLT
Learn XPath
Learn XQuery
×
References
HTML
HTML Tag Reference
HTML Browser Support
HTML Event Reference
HTML Color Reference
HTML Attribute Reference
HTML Canvas Reference
HTML SVG Reference
Google Maps Reference
CSS
CSS Reference
CSS Browser Support
CSS Selector Reference
Bootstrap 3 Reference
Bootstrap 4 Reference
W3.CSS Reference
Icon Reference
Sass Reference
JavaScript
JavaScript Reference
HTML DOM Reference
jQuery Reference
AngularJS Reference
AppML Reference
W3.JS Reference
Programming
Python Reference
Java Reference
Server Side
SQL Reference
MySQL Reference
PHP Reference
ASP Reference
XML
XML DOM Reference
XML Http Reference
XSLT Reference
XML Schema Reference
Character Sets
HTML Character Sets
HTML ASCII
HTML ANSI
HTML Windows-1252
HTML ISO-8859-1
HTML Symbols
HTML UTF-8
×
Exercises and Quizzes
Exercises
HTML Exercises
CSS Exercises
JavaScript Exercises
SQL Exercises
MySQL Exercises
PHP Exercises
Python Exercises
NumPy Exercises
Pandas Exercises
SciPy Exercises
jQuery Exercises
Java Exercises
C++ Exercises
C# Exercises
R Exercises
Kotlin Exercises
Go Exercises
Bootstrap Exercises
Bootstrap 4 Exercises
Bootstrap 5 Exercises
Git Exercises
Quizzes
HTML Quiz
CSS Quiz
JavaScript Quiz
SQL Quiz
MySQL Quiz
PHP Quiz
Python Quiz
NumPy Quiz
Pandas Quiz
SciPy Quiz
jQuery Quiz
Java Quiz
C++ Quiz
C# Quiz
R Quiz
Kotlin Quiz
XML Quiz
Bootstrap Quiz
Bootstrap 4 Quiz
Bootstrap 5 Quiz
Cyber Security Quiz
Accessibility Quiz
Courses
HTML Course
CSS Course
JavaScript Course
Front End Course
SQL Course
PHP Course
Python Course
NumPy Course
Pandas Course
Data Analytics Course
jQuery Course
Java Course
C++ Course
C# Course
R Course
React.js Course
Bootstrap 3 Course
Bootstrap 4 Course
XML Course
Cyber Security Course
Accessibility Course
Certificates
HTML Certificate
CSS Certificate
JavaScript Certificate
Front End Certificate
SQL Certificate
PHP Certificate
Python Certificate
Data Science Certificate
Bootstrap 3 Certificate
Bootstrap 4 Certificate
Bootstrap 5 Certificate
jQuery Certificate
Java Certificate
C++ Certificate
C# Certificate
React.js Certificate
TypeScript Certificate
XML Certificate
Cyber Security Certificate
Accessibility Certificate
Excel Certificate
×
Tutorials
References
Exercises
Get Certified
Spaces
Videos
Shop
Pro
C#
Tutorial
C# HOME
C# Intro
C# Get Started
C# Syntax
C# Output
C# Comments
C# Variables
C# Data Types
C# Type Casting
C# User Input
C# Operators
C# Math
C# Strings
C# Booleans
C# If...Else
C# Switch
C# While Loop
C# For Loop
C# Break/Continue
C# Arrays
C#
Methods
C# Methods
C# Method Parameters
C# Method Overloading
C#
Classes
C# OOP
C# Classes/Objects
C# Class Members
C# Constructors
C# Access Modifiers
C# Properties
C# Inheritance
C# Polymorphism
C# Abstraction
C# Interface
C# Enums
C# Files
C# Exceptions
C#
How To
Add Two Numbers
C#
Examples
C# Examples
C# Compiler
C# Exercises
C# Quiz
C# Certificate
C#
Examples
❮ Previous
Next ❯
C# Syntax
Create a simple "Hello World" program
Syntax Explained
C# Comments
Single-line comment before a line of code
Single-line comment at the end of a line of code
Multi-line comment
Comments Explained
C# Variables
Create a string variable
Create an integer variable
Create a variable without assigning the value, and assign the value later
Overwrite an existing variable value
Combine text and a variable on display
Add a variable to another variable
Declare many variables of the same type with a comma-separated list
Variables Explained
C# Data Types
A demonstration of different data types in C#
Create an int type
Create a long type
Create a float type
Create a double type
Create a bool type
Create a char type
Create a string type
Data Types Explained
C# Type Casting
Implicit casting
Explicit casting
Type conversion methods
Type Casting Explained
C# User Input
Get user input text
Get user input with numbers
User Input Explained
C# Operators
Addition operator
Subtraction operator
Multiplication operator
Division operator
Modulus operator
Increment operator
Decrement operator
Assignment operator
Addition assignment operator
Operators Explained
C# Math
Math.Max(x,y) - return the highest value of x and y
Math.Min(x,y) - return the lowest value of x and y
Math.Sqrt(x) - return the square root of x
Math.Abs(x) - return the absolute (positive) value of x
Math.Round() - round a number to the nearest whole number
Math Explained
C# Strings
Create a string
Find the length of a string
Using methods to convert strings to uppercase and lowercase
String concatenation
String concatenation with the Concat() method
String interpolation
Access characters in a string by referring to its index number
Find the index position of a specific character in a string, by using the IndexOf() method
Use the Substring() method together with the IndexOf() method
Use quotes in a string
Strings Explained
C# Booleans
Create a bool (boolean) type
Find out if an expression is true or false
Use the "equal to" operator to evaluate a boolean expression
Booleans Explained
C# If...Else (Conditions)
The if statement
The else statement
The else if statement
If...Else Explained
C# Switch
The switch statement
The switch statement with a default keyword
Switch Explained
C# Loops
While loop
Do while loop
For loop
foreach loop
Break a loop
Continue a loop
Loops Explained
C# Arrays
Create and access an array
Change an array element
Find the length of an array
Access and change an array element
Loop through an array
Loop through an array with foreach
Sort an array
Using System.Linq
Arrays Explained
C# Methods
Create and call a method
Call a method multiple times
Method with parameters
Default parameter value
Multiple parameters
Return value
Return the sum of a method's two parameters
Named arguments
Overload a method
Methods Explained
C# Classes and Objects
Create a class and an object of a class
Create multiple objects of a class
Use multiple classes for better organization
Access fields and methods
Create a class constructor
Constructor with parameters
Private modifier
Public modifier
Properties (get and set)
Automatic (short-hand) properties
Inheritance
Polymorphism
Abstraction
Interface
Multiple interfaces
Enums
Working with files
Classes and Objects Explained
C# Exceptions (Try...Catch)
The try...catch statement
The finally statement
Exceptions Explained
❮ Previous
Next ❯
NEW
We just launched
W3Schools videos
Explore now
COLOR PICKER
Get certified
by completing
a
course today!
w
3
s
c
h
o
o
l
s
C
E
R
T
I
F
I
E
D
.
2
0
2
2
Get started
CODE GAME
Play Game