static void Main(string[] args) { // Booleans // Declaration - type name; bool isDeclared; // Assigning a value isDeclared = true; // Declaring and assigning an initial value bool isDeclarationAndInitialized = false; isDeclarationAndInitialized = true; // Characters char letter = 'a'; char symbol = '?'; char number = '7'; char space = ' '; char specialCharacter = '\n'; Console.WriteLine(number / 5); // Whole Numbers byte byteExample = 255; sbyte signedByte = -128; short shortExample = 32767; Int16 anotherShortExample = -32000; int intMin = -2147483648; uint unsignedInt = 4000000000; Int32 intMax = 2147483647; long longExample = 9223372036854775807; Console.WriteLine(longExample + 1); // Decimals float floatExample = 2147483641.320561408513f; double doubleExample = 2147483641.320561408513d; decimal decimalExample = 2147483641.320561408513m; Console.WriteLine(floatExample); Console.WriteLine(doubleExample); Console.WriteLine(decimalExample); // Structs DateTime today = DateTime.Today; DateTime tomorrow = new DateTime(2020, 7, 28); // Enums PastryType myPastry = PastryType.Cake; PastryType anotherOne = PastryType.Eclaire; DayOfWeek dayOfWeek = DayOfWeek.Tuesday; Console.ReadLine(); }
public void Enums() { PastryType pastryType = PastryType.Cake; PastryType anotherOne = PastryType.Croissant; Console.WriteLine((int)anotherOne); }
static void Main(string[] args) { //boolean bool isDeclared; isDeclared = false; bool isDeclaredAndInitialized = false; //characters char character = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; //creates a new line // whole numbers byte byteExample = 255; //max number for a byte is 255 sbyte sByteExample = -128; short shortExample = 32767; Int16 anotherShortExample = 32767; //This is just another way to write a short int intMin = -2147483648; Int32 intMax = 2147483647; //another way to write an int long longExample = 9223372036854775807; Int64 longMin = -9223372036854775808; //another way to write a long int a = 7; int b = -7000; byte age = 104; // Decimals float floatExample = 1.045231f; double doubleExample = 1.789053278907036d; decimal decimalExample = 1.257890728904578978m; Console.WriteLine(1.257890728904578978f); Console.WriteLine(1.257890728904578978d); Console.WriteLine(1.257890728904578978m); // Enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime defaultExample = new DateTime(); int example = int.Parse("5"); Console.WriteLine(example.GetType()); Console.ReadLine(); }
public void Enums() { PastryType myPastry = PastryType.Doughnut; PastryType anotherOne = PastryType.Scone; Console.WriteLine(myPastry); Console.WriteLine(anotherOne); }
public void Enums() { PastryType myPastry = PastryType.Klondike_Bar; PastryType anotherOne = PastryType.Scone; Console.WriteLine(myPastry); Console.WriteLine(anotherOne); }
public void Enums() { PastryType myPastry = PastryType.donut; PastryType secondPastry = PastryType.scone; PastryType thirdPastry = PastryType.cake; Console.WriteLine(myPastry); Console.WriteLine(secondPastry); }
static void Main(string[] args) { // Bools bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; isDeclaredAndInitialized = true; // Char char character = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char special = '\n'; // Whole Numbers byte byteExample = 255; sbyte sByteExample = -128; short shortExample = 32767; Int16 anotherShortExample = 32000; int intMin = -2147483648; Int32 intMax = 2147483647; long longExample = 9223372036854775807; Int64 longMin = -9223372036854775808; int a = 7; int b = -7000; byte age = 104; // Decimals float floatExample = 1.045231f; double doubleExample = 1.789053278907036; decimal decimalExample = 1.25789072890457897897897897897897m; Console.WriteLine(1.25789072890457897897897897897897f); Console.WriteLine(1.25789072890457897897897897897897d); Console.WriteLine(1.25789072890457897897897897897897m); Console.ReadKey(); // Enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Danish; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1995, 12, 30); DateTime test = new DateTime(); }
public void Enums() { PastryType pastryType = PastryType.Baguette; PastryType anotherOne = PastryType.Cake; // Casting = converting one type to another Console.WriteLine((int)pastryType); Console.WriteLine((int)anotherOne); }
public void Enums() { PastryType pastryType = PastryType.Donut; PastryType anotherOne = PastryType.Cake; //Casting = converting one type to another Console.WriteLine(pastryType); Console.WriteLine(anotherOne); }
static void Main(string[] args) { bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; // isDeclaredAndInitialized = true; //can change value of variable code runs top to bottom char character = 'a'; //single quotes char symbol = '&'; char number = '5'; //cant be 55, cahr is only ever one char space = ' '; //note it can be space char specialCharacter = '\n'; //two character special rules \n means goto new line? --> action //null is nothing =/= 0 //whole numbers byte byteExample = 255; //255 is the highest it can go sbyte sByteExample = -128; short shortExample = 32767; //same as Int16 prefences to use one or int16 Int16 anotherShortExmaple = 32000; int intMin = -2147483648; //smallest value Int32 intMax = 2147483647; //max value of an integer long longExample = 9223372036854775807; //max value Int64 longMin = -9223372036854775808; //min value int a = 7; int b = -7000; //right side of the equal sign is what is run first. So -7000 processes first and then is assigned the variable of 'b' byte age = 104; //decimals float floatExample = 1.045231f; //f makes this a float f is very important double doubleExample = 1.789053278907036d; //d is the suffix --> not ciritcal to have d, it is the standard form. can be removed with no issues decimal decimalExample = 1.2578907289045789789789789787897m; //m suffix, very long decimal point Console.WriteLine(1.2578907289045789789789789787897f); //cw then tab tab opens the console write line Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); //when running with diff suffixes you can see there is a cut off point in decimals. Console.ReadKey(); //prompts user to say hey i need input // Enums -->declared outside of the class then used in the class --> static values that will not change PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; //Structs Int32 num = 42; //if value is unassigned it defaults to 0 DateTime today = DateTime.Today; //assigns value of today DateTime birthday = new DateTime(1805, 11, 24); //very powerful option use arrow keys to see 12 options DateTime test = new DateTime(); //do not use 'default' as a variable name... name with intent }
public void Enums() { PastryType myPastry = PastryType.Doughnut; PastryType mySecondPastry = PastryType.Cake; Console.WriteLine(myPastry); Console.WriteLine(mySecondPastry); }
public Pastery(string pasName, string pasPicture, PastryType pasType, float pasPrice, string pasComments, bool pasVegan, bool pasGlotanFree) { Name = pasName; ImageLink = pasPicture; Type = pasType; Price = pasPrice; Comments = pasComments; Vegan = pasVegan; GlotanFree = pasGlotanFree; }
static void Main(string[] args) { //Bools bool isDeclared; //declared isDeclared = true; //initialized bool isDeclaredAndInitialized = false; //code reads top down, so everything below this initialization will be false until told otherwise isDeclaredAndInitialized = true; //characters char character = 'a'; char symbol = '&'; char number = '5'; //character can only ever be 1 character, not 55 or av char space = ' '; char specialCharacter = '\n'; //Whole Numbers byte byteExample = 255; //8-bit unsigned integer sbyte sByteExample = -128; //8-bit signed integer short shortExample = 32767; //16-bit signed integer Int16 anotherShortExample = 32000; //16-bit signed integer (another name for short) int intMin = -2147483648; //32-bit signed integer Int32 intMax = 2147483647; //32-bit signed integer (another name for int) long longExample = 9223372036854775807; //64-bit signed integer Int64 longMin = -9223372036854775808; //64-bit signed integer (another name for long) int a = 7; int b = -7000; byte age = 104; //Decimals float floatExample = 1.045231f; //single precision floating number double doubleExample = 1.789053278907036d; //double precision floating number decimal decimalExample = 1.2578907289045789789789789787897m; Console.WriteLine(1.2578907289045789789789789787897f); //shortcut is cw tab tab Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); Console.ReadKey(); //Enums - assigned outside the class!!!! PastryType myPastry = PastryType.Danish; PastryType anotherOne = PastryType.Scone; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1990, 3, 21); DateTime test = new DateTime(); }
static void Main(string[] args) { // booleans bool isDeclared; isDeclared = true; bool isDelcaredAndInitialized = false; isDelcaredAndInitialized = true; // must be only 1 character and must use single quotes char character = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; // whole numbers byte byteExample = 255; //highest a byte can go - unsigned integer is 0 or positive (not negative) sbyte sByteExample = -128; // signed integer is negative, 0, or positive short shortExample = 32767; Int16 anotherShortExample = 32000; int intMin = -2147483648; Int32 intMax = 2147483647; long longExample = 9223372036854775807; Int64 longMin = -9223372036854775808; int a = 7; int b = -7000; byte age = 104; // decimals float floatExample = 1.045231f; //must have f in order to be a float otherwise it is a double double doubleExample = 1.789053278907036d; // double is defauklt type with decimal (d is not necessary) decimal decimalExample = 1.2578907289045789789789789787897m; Console.WriteLine(1.2578907289045789789789789787897f); Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); Console.ReadKey(); // enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; // structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime test = new DateTime(); }
static void Main(string[] args) { bool isDeclared;// a boolean that is declared isDeclared = true; bool isDeclaredAndInitialized = false;// a boolean that is declared then initialized to the value of false isDeclaredAndInitialized = true; char characters = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; //breaks the two character word, because not printed to screen, but telling the program to do something // Whole Numbers byte byteExample = 255; //highest byte can go sbyte sByteExample = -128; short shortExample = 32767; // 16 bit integer Int16 anotherShortExample = 32000; // 16 bit integer int intMin = -2147483648; //32 bit integer Int32 intMax = 2147483647; // 32 bit integer long longExample = 9223372036854775807; //64 bit integer maximum Int64 longMin = -9223372036854775808; //64 bit integer mininum int a = 7; int b = -7000; byte age = 104; //Decimals float floatExample = 1.045231f; double doubleExample = 1.789053278907036d; //d differeniates it from decimal decimal decimalExample = 1.2578907289045789789789789787897m; // m is suffix for decimal Console.WriteLine(1.2578907289045789789789789787897f); Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); Console.ReadKey(); //Enum PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime test = new DateTime(); }
static void Main(string[] args) { bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; isDeclaredAndInitialized = true; char character = 'a'; char symbol = '&'; char num = '5'; char space = ' '; char specialCharacter = '\n'; // new line character // Whole Numbers byte byteExample = 255; // range of byte type is -256 to 255 sbyte sByteExample = -128; // range of sbyte is -128 to 127 short shortExample = 32767; // range of short is 32768 to 32767 (?) Int16 anotherShortExample = -32768; // Int16 and short are the same int intMin = -2147483648; Int32 intMAx = 2147483647; // Int32 and int are the same long longExample = 9223372036854775807; // 9,223,372,036,854,775,807 Int64 longMin = -9223372036854775808; // Int64 is the same as long // Breakpointing - for debugger - @ LHS (left of the numbers) click & put a red dot on this line for debugger to stop // "Start" button will run up to & before this breakpoint. Step Into executes this line & points to next line. int a = 7; int b = -7000; byte age = 104; // Decimal Numbers float floatExample = 1.045231f; // float requires an 'f' suffix double doubleExample = 1.789053278907036d; // 'd' suffix is optional; defaults to double double doubleExample2 = 1.789053278907036; // max value of double decimal decimalExample = 1.2578907289045789789789789787897m; // 'm' suffix for decimal; this is max value Console.WriteLine(1.2578907289045789789789789787897f); // writes 1.257891 Console.WriteLine(1.2578907289045789789789789787897d); // writes 1.25789072890458 Console.WriteLine(1.2578907289045789789789789787897m); // writes 1.2578907289045789789789789788 Console.ReadLine(); // or Console.ReadKey() - what's the difference? // Enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; // Structs - number types are Structs but they have a default of 0 vs null (as with other Structs) Int32 numX = 42; // this is a Struct. It defaults to 0 DateTime today = DateTime.Today; // assign today's date DateTime birthday = new DateTime(1962, 10, 19); // new up an instance of DateTime; This has overloads - hover over the () and select ticks or kind / a year, month, day / }
static void Main(string[] args) { bool isDeclared; isDeclared = true; char character = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; byte byteExample = 255; sbyte sByteExample = -128; Int16 anotherShortExample = 32000; short shortExample = 32767; int intMin = -2147483648; Int32 intmax = 2147483647; long longExample = 9223372036854775807; Int64 longMin = -9223372036854775807; int a = 7; int b = -7000; byte age = 104; float floatExample = 1.045231f; double doubleExample = 1.789053278907036d; decimal decimalExample = 1.2578907289045789789789789787897m; Console.WriteLine(1.2578907289045789789789789787897f); Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); Console.ReadKey(); PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime test = new DateTime(); }
public void Enums() { PastryType myPastry = PastryType.KlondikeBar; PastryType anotherOne = PastryType.Cupcake; }
public void Enums() { PastryType myPastry = PastryType.Donut; PastryType anotherOne = PastryType.Croissant; }
static void Main(string[] args) { // Booleans // Declaration - type name; bool isDeclared; // Assigning a value isDeclared = true; // Declaring and initializing it bool isDelclaredAndInitialized = false; // can assign another value after being intitalized isDelclaredAndInitialized = true; // Characters // use single quotes to initialize types // (Kate Lockhart )=(14 characters) char letter = 'a'; char symbol = '?'; char number = '7'; char space = ' '; // the backslash will make a special char be seen as a character inside the '' char specialCharacter = '\''; // Whole Numbers //byte only goes from 0 to 255 byte byteExample = 0; //shorts 0 to 32767 short shortExample = 32767; Int16 anotherShortEx = -32000; //integer int intMin = -2147483648; //uint is an unsigned integer uint unsignedInt = 40000000; // long int has 64 bit max, largest of the signed numbers long longExample = 9223372036854775807; // Decimals //the only declaration type with suffixes //float will be a double unless you have a f to define it as float float floatExample = 1.320561408513f; //double can have a d to indicate its a double but it's optional double doubleExample = 1.320561408513d; //m is used to indicate decimal decimal decimalExample = 1.320561408513m; Console.WriteLine(floatExample); Console.WriteLine(doubleExample); Console.WriteLine(decimalExample); // Structs //always have a default value //date time itself is a type DateTime today = DateTime.Today; DateTime tomorrow = new DateTime(2020, 7, 29); // Enums PastryType myPastry = PastryType.Cake; PastryType anotherOne = PastryType.Eclaire; //DayOfWeek is a built out enum anyone can access DayOfWeek dayOfWeek = DayOfWeek.Tuesday; Console.ReadLine(); }
public void Enums() { PastryType myPastry = PastryType.Klondike_Bar; PastryType anotherOne = PastryType.Croissant; }
static void Main(string[] args) { // This is how you take notes // Bools bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; isDeclaredAndInitialized = true; // Characters - can only initialize single digits char character = 'a'; char symbol = '&'; char number = '3'; char space = ' '; char specialCharacters = '\n'; // Wole numbers // All numbers listed below have a certain number of digits // No quotes because you are assigning a numerical value byte byteExample = 255; // byte max is 255 ^^ sbyte sByteExample = -128; // represents an 8-bit signed integer // short and Int16 are the same short shortExample = 32767; Int16 anotherShortExample = 32767; //Int is most commonly used int intMin = -2147483648; // smallest an Int can be Int32 intMax = 2147483647; // highest an Int can be // long is longer than int - same as INT64 long longExample = 9223372036854775807; Int64 longMin = -9223372036854775808; int a = 7; int b = -7000; byte age = 104; // Decimals - // Float - MUST have the f at the end, // double- doesn't necessarily need the d float floatExample = 1.045231f; double doubleExample = 1.789053278907036d; decimal decimalExample = 1.2578907289045789789789789787897m; Console.WriteLine(1.2578907289045789789789789787897f); // prints 1.257891 Console.WriteLine(1.2578907289045789789789789787897d); // prints 1.25789072890458 Console.WriteLine(1.2578907289045789789789789787897m); // prints 1.2578907289045789789789789788 Console.ReadKey(); // Enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime test = new DateTime(); }
public void Enum() { PastryType myPastry = PastryType.Cake; PastryType anotherPastry = PastryType.Cupcake; }
static void Main(string[] args) { // Booleans // Declaration - type name; bool isDeclared; // Assigning a value isDeclared = true; // Declaring and assigning an initial value bool isDeclarationAndInitiliazed = false; isDeclarationAndInitiliazed = true; // Characters char character = 'a'; char symbol = '?'; char number = '7'; char space = ' '; char specialCharacter = '\''; // Add \ inside '' to use special characters // \n creates new line in console Console.WriteLine(specialCharacter); // Whole numbers byte byteExample = 255; // Byte can only go to 255. 0 counts as a number in a byte // use a byte if you need a small number // cannot be a negative number sbyte signedByte = -128; // sbyte can only go to -128 short shortExample = 32767; //32767 is max number Int16 anotherShortExample = -32000; // use short instead of Int16 int intMin = -2147483648; uint unsignedInt = 400000000; // min value is 0 on uint so it can't be negative //signed can go negative // unsigned is only positive long longExample = 9223372036854775807; Console.WriteLine(longExample + 1); //Decimals float floatExample = 1.320561408513f; double doubleExample = 1.320561408513d; decimal decimalExample = 1.320561408513m; // Structs // Always has a default value DateTime today = DateTime.Today; DateTime tomorrow = new DateTime(2020, 7, 29); // Enums PastryType myPastry = PastryType.Cake; PastryType anotherOne = PastryType.Eclaire; DayOfWeek dayOfWeek = DayOfWeek.Tuesday; Console.ReadLine(); }
public void Enums() { PastryType myPastry = PastryType.Croissant; Console.WriteLine(myPastry); }
public void Enum() { PastryType myPastry = PastryType.Eclaire; PastryType anotherPastry = PastryType.Danish; }
static void Main(string[] args) { // Bools bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; isDeclaredAndInitialized = true; char character = 'a'; char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; //Whole Numbers byte byteExample = 255; //Max value = 255 sbyte sByteExample = -128; //This next two are the same thing. short shortExample = 32767; Int16 anotherShortExample = 32000; int intMin = -2147483648; Int32 intMax = 2147483647; long longExampleMax = 9223372036854775807; Int64 longMin = -9223372036854775808; int a = 7; int b = -7000; //terminal runs -7000 first and stores it as b next byte age = 104; // Decimals float floatExample = 1.045231f; //needs a f double doubleExample = 1.789053278907036d; //you can either put a d or not decimal decimalExample = 1.2578907289045789789789789787897m; //needs a m Console.WriteLine(1.2578907289045789789789789787897f); Console.WriteLine(1.2578907289045789789789789787897d); Console.WriteLine(1.2578907289045789789789789787897m); // Enums PastryType myPastry = PastryType.Croissant; PastryType anotherOne = PastryType.Donut; //Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1805, 11, 24); DateTime test = new DateTime(); int first = 7; int second = 2; int quo = first / second; Console.WriteLine(quo); int code = 17; int quantity = 55; int temp = code; code = quantity; quantity = temp; Console.WriteLine(quantity); Console.WriteLine(code); int[] allNums = { 1, 2, 3, 4, 5 }; int index = 0; while (index <= 5) { Console.WriteLine($"Last index {allNums[index]}"); index++; } Console.ReadKey(); //This stops the code and tells the user that it needs some sort of input/command }
static void Main(string[] args) { /// ctrl+e+w activates word wrap (same as alt+z in visual studio code) /// ctrl+k+d cleans up code (if stuff is out of line it'll reindent/deindent, etc) /// ctrl+shift+/ comments out selected code /// shortcut for Console.WriteLine: type cw and hit tab twice bool isDeclared; isDeclared = true; bool isDeclaredAndInitialized = false; isDeclaredAndInitialized = true; char character = 'a'; // char denotes a single character; uses 'single quotes'. // Differs from string in use of single quotes and length (char is only 1, string can have /many/) char symbol = '&'; char number = '5'; char space = ' '; char specialCharacter = '\n'; // \n = new line byte byteExample = 255; // 255 is the max for byte sbyte sByteExample = -128; short shortExample = 32767; Int16 anotherShortExample = 32000; // Int16 == short int intMin = -2147483648; // int is most common whole number variable designation Int32 intMax = 2147483647; // Int32 == int long longExample = 9223372036854775807; Int64 longMin = -9223372036854775808; // Int64 == long // most of these aren't used that often; mostly just use int int a = 7; // break point: click on the bar with the red dot to add a red dot; when you run the code it'll pause on the line int b = -7000; byte age = 104; float floatExample = 1.045231f; // floats need to have an f at the end double doubleExample = 1.789053278907036d; // can end in a d, but doesn't have to. Numbers w/ decimal points default to doubles if there's no suffix decimal decimalExample = 1.2578907289045789789789789787897m; // ends in m Console.WriteLine(1.2578907289045789789789789787897f); // will cut off at float's limit Console.WriteLine(1.2578907289045789789789789787897d); // will cut off at double's limit Console.WriteLine(1.2578907289045789789789789787897m); // within decimal's limit so it won't cut off Console.ReadKey(); /// Enums // Enums must be defined outside the class (so return to the top) PastryType myPastry = PastryType.Cake; PastryType anotherOne = PastryType.Croissant; /// Structs Int32 num = 42; DateTime today = DateTime.Today; DateTime birthday = new DateTime(1995, 10, 02); DateTime defaultTest = new DateTime(); }