DEV Community

Ruxin Qu
Ruxin Qu

Posted on • Edited on

C#: Console and datatypes

  1. Console.WriteLine("Hello World") prints the output on the existing line and appends a new line after it. Console.Write("hello"); Console.Write("World"); print in the same line
  2. .WriteLine() and .Write() are both methods in the class Console
  3. comparison operators: > < >= <=
  4. equality and inequality operator: == !==
  5. logical negation operator: !
  6. declare a string : string myString = "This is a string";
  7. string method: Contains(), StartsWith(), EndsWith(), ToLower(), ToUpper(), Trim()
  8. A literal value is a constant value that never changes. There are 5 common literal data types.
  • character literals: one single alphanumeric character, Console.WriteLine('b') single quotes create a char literal and double quotes create a string literal
  • integer literals: int
  • floating-point number: float append letter F after the number,double and decimal add letter m or M will both work
  • boolean
  1. implicitly typed: var (Note: This doesn't equal to dynamically typed)
  2. Using template literals and string interpolation allows easy way to interpolate variables and expressions Console.WriteLine($"Hello {firstName}!")

Top comments (0)