using System;
public class Program
{
public static void Main()
// Use const to create constant numbers; these are immune to being changed
// This is no longer a "variable" since it won't vary -- its a constant
const int myNumber = 8;
// ^ Modern compilers will actually ignore variables/constants like this that are never actually used in the program
// Hard coding is using direct numbers instead of variables
int [] numbers =
1, // Structuring an array like this allows
5,
22, // you to use comments for each entry, which can be useful for complicated arrays or lists
0,
13, // Use a comma even after the last one, it won't break anything
};
// These above are not hard coded since they're only assigned once
// Numbers should only appear where they're being assigned to something that can later be refered to by name
// foreach() can be used to go through a collection/array, using the arguments (type singular in plurals)
// per convention, the singular naming is used for the singular type, and plural naming for the array type
foreach(int number in numbers)
Console.WriteLine(number);
}
// You can use var to let the compiler figure out the variable type -- it will, but it makes it less readable for humans
// this allows you to change up the type of the array (numbers from int to float for example) without destroying your foreach statement
// the singular "number" stays constant for each iteration, but some programming languages will let you play with them in iterations (Java)
// but it will fix itself after each iterations
foreach(var number in numbers)
/*
Multiple cores allow multiple sections of code to be processed.
Constants allow multithreaded code to remain safe.
It can be difficult to synchronize between cores when one core has changed something.
Whenever possible, prefix with const to keep things running smoothly in the near or distant future.
bytes are 8 bit, ints are 32 bit
you can assign the value of a byte to an int, but not the opposite -- even if it will fit
=> You must (cast) the value to a byte to fit it into a byte type
The programmer needs to check if that's possible; the compiler won't know to check it
Compiler will simply throw out all the bits above the limit if you overfill a data type
Downcasts are explicity -- taking a wider thing into a small thing
Upcasts are implicit -- cast little things into wider things just fine
foreach might be dangerous, it seems to allow impicit downcasting which has potential to be pretty bad
ensure you manually check
*/