C# Cheat Sheet

This cheat sheet is a valuable resource for anyone who wants to learn C#. It is a quick and easy way to learn about the most common C# syntax, keywords, and concepts, and it can help you to write efficient and robust applications.

C# (pronounced C sharp) is a programming language developed by Microsoft and widely used for building various applications, including desktop, web, and mobile applications. With C#, you can create dynamic and functional programs using its rich features and libraries. By referring to a C# cheat sheet, you can quickly grasp the language's fundamental syntax, keywords, and concepts. This will enable you to write clean, maintainable code that performs well, enhancing the overall quality of your applications.

C# Cheat Sheet

This cheat sheet is a valuable resource for anyone who wants to learn C#. It is a quick and easy way to learn about the most common C# syntax, keywords, and concepts, and it can help you to write efficient and robust applications.

C# (pronounced C sharp) is a programming language developed by Microsoft and widely used for building various applications, including desktop, web, and mobile applications. With C#, you can create dynamic and functional programs using its rich features and libraries. By referring to a C# cheat sheet, you can quickly grasp the language's fundamental syntax, keywords, and concepts. This will enable you to write clean, maintainable code that performs well, enhancing the overall quality of your applications.

C# quick reference cheat sheet

Data Types:

  • int: Represents whole numbers.

  • double: Represents floating-point numbers with double precision.

  • char: Represents a single character.

  • string: Represents a sequence of characters.

  • bool: Represents a Boolean value (true or false).

Variables:

Declaration: <data_type> <variable_name>; Example: int age;

Operators:

  • Arithmetic Operators:

    • + Addition

    • - Subtraction

    • * Multiplication

    • / Division

    • % Modulo

  • Comparison Operators:

    • == Equal to

    • != Not equal to

    • > Greater than

    • < Less than

    • >= Greater than or equal to

    • <= Less than or equal to

  • Assignment Operators:

    • = Assigns a value to a variable

    • += Adds and assigns

    • -= Subtracts and assigns

    • *= Multiplies and assigns

    • /= Divides and assigns

Control Structures:

  • if-else Statement: if (<condition>) { // Code to execute if the condition is true } else { // Code to execute if the condition is false }

  • for Loop: for (<initialization>; <condition>; <increment>) { // Code to execute repeatedly }

  • while Loop: while (<condition>) { // Code to execute repeatedly while the condition is true }

Methods:

Declaration: <access_modifier> <return_type> <method_name>(<parameter_list>)

Example: public int AddNumbers(int num1, int num2) { int sum = num1 + num2; return sum; }

Classes:

Declaration: class <class_name> {}

Example: public class Person { public string Name { get; set; } public int Age { get; set; } }

Exception Handling:

Example: try { // Code that may throw an exception } catch (Exception ex) { // Code to handle the exception } finally { // Code that always executes, regardless of whether an exception occurred or not }

Learn more C# skills on Coursera.

C# Courses在新标签页中打开 | Unity Courses在新标签页中打开 | Game Development Courses在新标签页中打开 | .NET Courses在新标签页中打开 | Object Oriented Programming Courses在新标签页中打开 | Programming Fundamentals Courses在新标签页中打开 | Game Design Courses在新标签页中打开 | Software Development Courses在新标签页中打开 | Algorithms Courses在新标签页中打开 | C++ Courses在新标签页中打开 | SQL Courses在新标签页中打开

CommunityJoin a community of over 100 million learners from around the world
CertificateLearn from more than 200 leading universities and industry educators.
Confidence70% of all learners who have stated a career goal and completed a course report outcomes such as gaining confidence, improving work performance, or selecting a new career path.
All courses include:
  • 100% online
  • Flexible schedule
  • Mobile learning
  • Videos and readings from professors at world-renowned universities and industry leaders
  • Practice quizzes

Can’t decide what is right for you?

Try the full learning experience for most courses free for 7 days.

注册以在 Coursera 社区与来自全球的 87 百万学生一起学习