C# Fundamentals

Thursday, November 27, 2014

File new project console application


Display a line of text in the console, press ctrl + f5 to execute


Use escape sequence backslash n to position on next line


Overload writeline method to format string, specified in first argument, curly braced numbers are placeholder for subsequent argument


A simple program adding two numbers


Equality and relational operators


Add a new class to the project


Add a public method to the class that writes a line to the console


Create an instance of the class, it is now an object and invoke the method on it


Add a parameter to the method and print it to the console


In method invocation pass in an argument


Prompt for user input, pass user input into method invocation


Add a public property, auto-implemented to get and set the value of the metric, in the method get the value of the property


In client code, get the value of the metric and set the value of the metric


Constructor is used to initialize an object as its created, initialize property with string supplied as argument


Create an instance of the object, pass in the metric in the constructor


Add a new class to the project


The account class


The calling code


Add the calculate method


In calling code invoke show and calculate methods, integers truncate any floating points


Employee average using sentinel controlled repetition


The calling code, press ctrl+f5 to execute


Nested control statements, if else in while


Type in 10 values, view the results


Add an if clause if passes greater than eight print message to console


Any statement that has an assignment operator and arithmetic operator can be rewritten using a compound operator like this


Increment and decrement operators


View results in console


The while loop


The for loop


Use for loop to sum up even integers from zero to ten


Compound interest calculation


View output in console


The do while loop runs at least once


The calling code creates an instance of the class and invokes three methods that do the work


Declare instance variables to keep track of the metrics, the showmessage method prints the welcome message


The getappraisals method loops through and grabs user input, invokes increment method to increment the appropriate counter


The incrementletterperformance method uses a switch statement to increment the variables based on the input, case nine falls through to ten, default, anything beneath six, fcounter is incremented


The show report method


View output in console


Default Success Warning Important Info Inverse
B S W I ? O