📒
Notes
Cloud ComputingData Science/AIGame Development
  • Home
  • Big O
  • Data Structures & Algorithms
    • Data Structures
      • Array
      • Stack
      • Queue
      • Linked List
      • Binary Tree
    • Algorithms
      • Searching
      • Sorting
      • Graphs
        • Searching
        • Minimum Spanning Tree
        • Shortest Path Algorithms
      • String Algorithms
  • Object Oriented Programming
  • Languages
    • HTML/CSS
      • CSS
    • C++
    • C#
      • Types
      • Keywords
        • Modifiers
          • Access Modifiers
        • Method Parameters
      • Operators and Expressions
      • Collections
      • Constructors
      • Delegates
      • Indexers
      • Concepts
      • Features
        • LINQ
          • Operators
          • Working with Data
          • Methods
          • Resources
        • Asynchronous Programming
        • Reflection
    • Dart
    • GraphQL
    • JavaScript
      • Variable and Parameter
      • Built-in objects
        • Array
        • Built-in Functions
      • Functions
      • Classes
      • Prototype
      • Libraries
        • jQuery
        • React
          • Components
          • State and Lifecycle
          • Hooks
            • useState
            • useEffect
          • Resources
      • Testing Framework
      • Web APIs
    • Kotlin
      • Basics
    • Python
      • Basics
      • Data Structures
      • Functions
      • Resources
        • Flask
    • SQL
      • Basics
      • Operators
      • JOINs
      • Aggregations
      • Subqueries
      • Views
      • Functions
        • Window Functions
      • Stored Procedures
      • Performance Tuning
      • Extras
    • Resources
  • 🌐Web Frameworks
    • Angular
      • Templates
      • Directives
        • Attribute Directives
        • Structural Directives
    • ASP.NET
      • Fundamentals
        • Dependency Injection
        • Middleware
        • Session & State Management
      • Web apps
        • MVC
          • Controllers
            • Filters
          • Models
            • Model Binding
            • Model Validation
          • Views
            • Tag Helpers
            • View Components
          • Features
        • Client-side development
      • Web APIs
        • Controller-based APIs
        • Minimal APIs
        • OpenAPI
        • Content Negotiation
      • SignalR
      • Host and Deploy
        • IIS
      • Security
    • Django
      • The Request/Response Cycle
    • Terminologies
      • Web Server
        • Internet Information Services
    • Resources
  • 📱App Frameworks
    • Introduction
      • Resources
    • Xamarin
      • Lifecycle
      • Custom Renderers & Effects
      • Behaviors
      • Triggers
      • Gestures
      • Commands
      • Dependency Service in XF
      • Libraries
      • Showcase
    • .NET MAUI
      • Controls
      • Navigation
      • Storage Options
  • Multi-Platform Frameworks
    • .NET
      • .NET Framework
        • ADO.NET
        • WCF
      • Fundamentals
        • Logging
        • Testing
      • Advanced
        • Asynchronous Programming
        • Parallel Programming
        • Threading
        • Memory Management
          • Garbage Collection
    • Flutter
  • Object-Relational Mappers
    • Entity Framework
      • Application Models
      • Configuration
      • Setting Up
      • Advanced
  • Databases
    • Introduction
      • DBMS Architecture
      • Normalization
      • Database Transaction Models
    • Relational Databases
      • Microsoft SQL Server
        • Basics
        • Functions
        • Stored Procedures
        • Error Handling
        • Log Shipping
        • Querying and Manipulating JSON data
        • Statements
        • Topics
        • Extras
    • Non-Relational Databases
      • MongoDB
      • Redis
        • Data Structures
        • Introduction
        • Managing Database
  • Tools
    • Version Control
      • Git
        • Setup and Config
        • Basics
          • Sharing and Updating Projects
        • Resources
      • Perforce Helix
    • GitHub
    • Powershell
  • Software Development
    • Software Development Life Cycle
    • Software Design Patterns
      • GoF Design Patterns
      • Architectural Patterns
        • MVC
        • MVVM
        • N-tier Architecture
        • Onion Architecture
        • Data Transfer Objects
      • CQRS
    • Software Design Principles
      • S.O.L.I.D. Priniciple
  • System Design
    • Topics
      • Load Balancing
  • Topics
    • JWT
    • Caching
      • Static vs Dynamic Caching
    • OSI model
      • HTTP
    • Glossary
    • API
      • SOAP
      • REST
    • Microservices
    • WebHooks
    • Practice
    • Operating Systems
      • Windows
    • Architecture
  • 🔖Bookmarks
  • 🔗Resources
Powered by GitBook
On this page
  • Datatypes/Literals
  • Variables

Was this helpful?

  1. Languages

C#

Programming Language designed by Anders Hejlsberg.

PreviousC++NextTypes

Last updated 7 months ago

Was this helpful?

The parentheses are known as the method invocation operator.

Datatypes/Literals

  • string - for words, phrases, or any alphanumeric data enclosed by double-quotes.

  • char - for a single alphanumeric character enclosed by single quotes.

  • int - for a numeric whole number.

  • decimal - for a number with decimal values and m/M as a literal suffix.

  • bool - for a true/false boolean values.

Console.WriteLine("Hello, World!");    //string

Console.WriteLine('a');                //char

Console.WriteLine(123);                //int

Console.WriteLine(123.456m);            //decimal
Console.WriteLine(123.456M);                    

Console.WriteLine(true);                //bool
Console.WriteLine(false);

Note

string and char are only used for presentation, not for calculation.

Variables

  • Variables are temporary values you store in the computer's memory.

  • Before you can use a variable, you have to declare it.

  • To declare a variable, you first select a data type for the kind of data you want to store and then give the variable a name that follows the rules.

bool processedCustomer;
char userOption;
decimal particlesPerMillion;
int gameScore;
string firstName;
  • You must assign (set) a value to a variable before you can retrieve (get) a value from a variable.

  • You can initialize a variable by assigning a value to the variable at the point of declaration.

  • Assignment happens from right to left.

  • You use a single equals character as the assignment operator.

An implicitly typed local variable is created using the var keyword. The var keyword tells the compiler to infer the data type of the variable based on the value it is initialized to.

var message = "Hello world!";

Note

You can only use the var keyword if the variable is initialized.

An string/character escape sequence is a special instruction to the runtime that you want to insert a special character that will affect the output of your string.

  • \u - add encoded characters in literal strings, then a four-character code representing some character in Unicode (UTF-16).

Console.WriteLine("\u3053\u3093\u306B\u3061\u306F World!");

Output: こんにちは World!

By default, all class members are sealed and cannot be overridden. To override we must expose it by using abstract or virtual keyword.

C# | Modern, open-source programming language for .NETMicrosoft
C# language referenceMicrosoftLearn
Logo
10 Advanced C# Interview Questions and Answers for 2022
Logo
C# Coding Conventionsdocsmsft
Logo
C# at Google Style Guidestyleguide
Logo