Posts

Showing posts from February, 2020

Post #6 Methods, procedures or encapsulation

Methods: Let me just give a base definition of a method. A method is a program that can take parameters and does something usually. The greatest of these is our main method which will always run when we run the program. The main method is also a built in method. You can have built in methods or you can build your own. Built in methods are super useful like the main method. It can also be good to build your own so that the method does what you want. Static Methods are methods that do not change. They don't normally allow methods that are not static to be called. However you can simply create a separate class. Instance Methods are methods that operate normally on a given instance of a class. Virtual Methods are when an instance method has an virtual modifier. That's the basic definition my books are giving me. Override Methods are when an instance method has an override modifier. Override Methods can override virtual methods. Sealed methods similar to virtual and override but whe...

Post #5 Repeated action syntax

Loops: Today we will be talking about loops. I unfortunately do not mean fruit loops. Loops are a repeated action in programs until a condition is completed. If there is no condition restraining a loop and no break in the loop than you have created a forever loop. This will kill most programming and probably crash your computer. If this shall happen than close or exit the program or turn off your computer. There are four loops in C#. These are while, do, for, and foreach. While Loops: While loops are super simple. They repeat until a condition is false.  Do Loops: Do is similar to while only it can and will go forever. Visual studio and C# are smart of enough to error you out so that this doesn't happen. A do loop will keep going until its while is false. As the previous sentence stated do loops have a while condition. While condition is false it will keep going.  For Loops: For loops are another kind of loop that usually depend on integers. For a variable, while so...

Post #4 Conditional Statements

Conditional Statements:  Conditional Statements   in programming are statements that give different results depending on a value. They require certain conditions to give different results. C# is no exception to this definition. The if statement is the main conditional statement used for C#. If statements require a condition or multiple conditions to be completed to give a specific result. If statements can have multiple parts. You can just write if, you can also write if else, or even if else if else. If statements are obviously used the same way they are in Java. Switch statements are another type of conditional. A switch statement checks the value of a variable against a number of conditions. Switch statements are similar to if statements. There is a difference. Switch statements only check the value of one variable to conditions. Using the word conditions might be a little confusing so borrowing a word from C# and the creator of C# these are cases not conditions. A variable...

Post #3 Costants Variables and Arithmetic Operations

Variables: First let's discuss variables. There are basically the same variable types we have seen before in Java(char, int, string, Boolean, float, and double, etc). They work pretty much the same way. There does seem to be an indication of at least one major change. That is that a variable can only work within its scope. Similar to how in Java a variable can't be used outside of it's method, for C# it can't be used outside it's scope. A scope is basically just a range limit which you can place anywhere. Normally of course you place your variables at the top of the main method after the beginning curly brace. Those are your basic global variables. This is a little weird but you can throw a set of curly braces anywhere and create a scope inside your main method. When you initialize a variable in a scope it cannot be used outside of it. If the variable is directly inside the main method it can be used in all scopes because it's a global variable for the main meth...