Update for 22-02-22 15:15

This commit is contained in:
Tyler Perkins 2022-02-22 15:15:01 -05:00
parent 4f17a427bb
commit a8bde7a353

View File

@ -46,6 +46,87 @@ Or call convert
== strings == == strings ==
* indexing starts at zero
* mystring.length
* mystring[0]
* haystack.IndexOf("Needle")
* haystack.IndexOf("N")
* haystack.Substring(2)
* haystack.Substring(1,3)
== operators ==
* normal + - * /
* Order of operations is preserved
* Modulous is %
* Operations on ints give ints
* += -= *= /= all work
* ++ and -- work
* Math.Pow(base, power)
* Math.Sqrt(144) = 12
* Math.Round(2.7) = 3
== ArrayList ==
* in System.Collections
{{{
ArrayList friends = new ArrayList();
friends.Add("Bob");
friends.Add("Mike");
}}}
== Exceptions ==
{{{
try {
int division = 10 / Convert.ToInt32(Console.ReadLine());
} catch(DivideByZeroException e) {
Console.WriteLine(e);
} catch(Exception e){
Console.WriteLine($"Unkown Error: {e}");
}
}}}
{{{
throw new DivideByZeroException("Cant add that... My Custom error is here");
}}}
== Constructors ==
Called at creation of class, same as C/C++ constructors.
this.xyz is also valid.
== Abstraction ==
declare a class as `abstract`.
To override a class add the modifier `override`.
== Interfaces ==
An interface is a fully abstract class that can be inherited by other classes.
It provides some set functions to be implimented by the child class.
{{{
public interface Animal{
void Speak();
}
public class Dog : Animal {
public void Speak(){
Console.WriteLine("Woof Woof");
}
}
public class Cat : Animal {
public void Speak(){
Console.WriteLine("Meow");
}
}
}}}
== Examples == == Examples ==
=== Hello World === === Hello World ===