|
Length
|
Returns the number of characters in a string.
|
|
IndexOf
|
Finds the index of the first occurrence of a specified character or substring.
|
|
Substring
|
Retrieves a portion of the string based on a specified index or length.
|
|
ToUpper and ToLower
|
Converts a string to uppercase or lowercase, respectively
|
|
Trim
|
Removes leading and trailing whitespace characters from a string.
|
|
Replace
|
Replaces all occurrences of a specified character or substring with another.
|
|
Split
|
Splits a string into an array of substrings based on a specified delimiter.
|
|
Concat
|
Concatenates multiple strings into a single string.
|
|
Format
|
Formats a composite string by replacing placeholders with corresponding values.
|
|
Compare
|
Compares two strings and returns an integer indicating their relative order.
|
|
Contains
|
Determines whether a specified character or substring exists within a string.
|
|
StartsWith and EndsWith
|
Checks if a string starts or ends with a specified character or substring.
|
|
PadLeft and PadRight
|
Adds padding characters to the left or right of a string to achieve a specified length.
|
|
IsNullOrEmpty and IsNullOrWhiteSpace
|
Checks if a string is null, empty, or consists only of whitespace characters.
|
|
Join
|
oncatenates an array of strings into a single string, using a specified delimiter.
|
|
ToCharArray
|
Converts a string to an array of characters.
|
|
CompareTo
|
Compares two strings and returns an integer indicating their relative order.
|
|
Substring (overload with start index and length)
|
Retrieves a substring from a string, starting at a specified index and with a specified length.
|
|
Remove
|
Deletes a specified number of characters from a string, starting at a specified position.
|
|
Equals
|
Compares two strings for equality, taking into account culture-specific or case-sensitive comparisons.
|
|
&&
|
AND
|
|
||
|
OR
|
|
+
|
Add
|
|
-
|
Subtract
|
|
*
|
Multiply
|
|
/
|
Divide
|
|
%
|
Modulo
|
|
++
|
Increase 1
|
|
--
|
Decrease 1
|
**string[] planets =**
** {**
** "Mercury", "Venus", "Mars",**
** "Earth", "Jupiter", "Saturn", **
** "Uranus", "Neptune", "Pluto"**
** };**
** for (int i = 0; i < planets.Length; i++)**
** {**
** Console.WriteLine(planets[i]);**
** }**
** foreach (string planet in planets)**
** {**
** Console.WriteLine(planet);**
** }**
-----------------------------------
**array sort & reverse:**
**string[] names = { "Jane", "Frank", "Alice", "Tom" };**
** Array.Sort(names);**
** foreach (string name in names)**
** {**
** Console.Write(name + " ");**
** }**
**Array.Reverse(names);**
** foreach (string name in names)**
** {**
** Console.Write(name + " ");**
** }**
**switch(expression) {**
** case constant-expression1 :**
** statement(s);**
** break;**
** case constant-expression2 :**
**case constant-expression3 :**
** statement(s);**
** break;**
** /* you can have any number of case statements */**
**default : /* Optional */**
**statement(s);**
**}**
**--Classes--**
**class Car **
**{**
**string color = "red";**
**}**
**--Object--**
**class Car **
**{**
** string color = "red";**
** static void Main(string[] args)**
** {**
** Car myObj = new Car();**
** Console.WriteLine(myObj.color);**
** }**
**}**
**--Multiple Objects--**
**class Car**
**{**
** string color = "red";**
** static void Main(string[] args)**
** {**
** Car myObj1 = new Car();**
** Car myObj2 = new Car();**
** Console.WriteLine(myObj1.color);**
** Console.WriteLine(myObj2.color);**
** }**
**}**
|
<
|
Less than
|
|
>
|
Greater than
|
|
<=
|
Less than or equal to
|
|
>=
|
Greater than or equal to
|
|
==
|
Equal to
|
|
!=
|
Not equal to
|
|
=
|
Assignment
|
|
+=
|
Add
|
|
-=
|
Subtract
|
**List<int> number = new()**
** {**
** 4, 6, 8, 1, 10, 2, 7, 3, 9, 5**
** };**
** number.Add(12);**
** number.Add(11);**
** number.Remove(1);**
** number.Sort();**
**foreach (int num in number)**
**{**
** Console.WriteLine(num);**
** }**
**---------------------------------**
** List<string> word = new()**
** {**
** "Delta", "Charlie", "Bravo", "Foxtrot", **
** "Echo", "Alpha", "Golf"**
** };**
** word.Add("India");**
** word.Add("Hotel");**
** word.Remove("Alpha");**
** word.Sort();**
** foreach (string phonetic in word)**
** {**
** Console.WriteLine(phonetic);**
** }**
|
Implicit Casting (automatically)
|
converting a smaller type to a larger type size char -> int -> long -> float -> double.
|
|
Explicit Casting (manually)
|
converting a larger type to a smaller size type double -> float -> long -> int -> char.
|
|
bool
|
Represents a Boolean value, either true or false.
|
|
char
|
Represents a single Unicode character.
|
|
string
|
Represents a sequence of characters.
|
|
int
|
Represents signed integers (whole numbers) within the range -2,147,483,648 to 2,147,483,647.
|
|
double
|
Represents double-precision floating-point numbers with decimal values. Sufficient for storing 15 decimal digits
|
|
decimal
|
Represents decimal numbers with high precision and a larger range.
|
|
float
|
Represents single-precision floating-point numbers with decimal values. Sufficient for storing 6 to 7 decimal digits
|
|
long
|
Represents signed integers with a larger range than int, from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
|
|
DateTime
|
Represents dates and times.
|
**namespace MyApplication**
**{**
** class Program**
** {**
** static void Main(string[] args)**
** {**
** MyMethod();**
** }**
** static void MyMethod()**
** {**
** Console.WriteLine("I have a red banana");**
** }**
** }**
**}**
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.