random numbers
random rnd = new random
int num = rnd.next(1,10);
for loops
for (int i = 1 ; i<= 10 ; i++)
{
}
boolean operators
and &&
or ||
not !
arrays
string[] countries = new string[3]
countries[0] = “a”
countries[1] = “b”
countries[2] = “c”
2d arrays
string[,] stationtimes = new string[,] {
{“ 7.30“ ,“ 8.30“,“12.45 “,“ 16.20“}',
{“ 7.30“ ,“ 8.30“,“12.45 “,“ 16.20“}'};
console.writeline(stationtimes[1,2]);
string manipulation-length of string
string mystring = “hello world“;
int lenofstring;
lenofstring = mystring.length;
record/structures
private struct employee
{
public string first name
public string surname
public string phone extension
}
static void main(string[] args)
{
employee1.firstname =”will”
employee1.surname = “smith”
employee1.phoneextention = “1701”
string manipulation-searching for character in a string
string email = “test@gmail.com”;
string searchcharacter = “@”;
int position
position = email.IndexOf(searchcharacter);
console.writeline(position);
string manipulation- substring
string str;
string retstring;
str = “this is a substring test”;
retstring = str.substring(10,9);
consolee.writeline(retstring);
string conversion
string string1 = “2343”;
int string1convert = int.parse(string1)
console.writeline(“string1convert”)
string as an array of chars
string mystring = “hello world”;
for(int i = 0; i < mystring.length; i++)
{
console.writeline(mystring[i[);
}