Wednesday, April 2, 2014

Use logical operators to check conditions

1) The != operator works a lot like ==, except it’s true if the two things you’re comparing are not equal.

2) You can use > and < to compare numbers and see if one is bigger or smaller than the other.

3) The ==, !=, >, and < operators are called conditional operators. When you use them to test two variables or values, it’s called performing a conditional test.

4) You can combine individual conditional tests into one long test using the && operator for AND and the || operator for OR. So to check if i equals 3 or j is less than 5, do (i == 3) || (j < 5).

5)  E.g private void button2_Click(object sender, EventArgs e)
{
int x = 5;
if (x == 10)
{
MessageBox.Show(“x must be 10”);
}
else
{
MessageBox.Show(“x isn’t 10”);
}
}

private void button3_Click(object sender, EventArgs e)
{
int someValue = 4;
string name = “Bobbo Jr.”;
if ((someValue == 3) && (name == “Joe”))
{
MessageBox.Show(“x is 3 and the name is Joe”);
}
MessageBox.Show(“this line runs no matter what”);
}

Don’t confuse the two equals sign operators!

1) You use one equals sign (=) to set a variable’s value

2) two equals signs (==) to compare two variables.


Loop Functionality

1) while (x > 5)
{
x = x - 3;
}
In a while loop, all of the statements inside the curly brackets get executed as long as the condition in the
parentheses is true.

2) for (int i = 0; i < 8; i = i + 2)
{
MessageBox.Show(“I’ll pop up 4 times”);
}

Every for loop has three statements. The first sets up the loop. The statement will keep looping as long as
the second one is true. And the third statement gets executed after each time through the loop.

use variables to work with data

1) A variable is what your program uses to store data.

2) Whenever you declare a variable, you tell your program its type and its name.

3) int maxWeight;    string message;      bool boxChecked; variable Types
   
    int myHeight = 63;

What Is CLR

1) When you double-click on the executable, Windows runs your program.
But there’s an extra “layer” between Windows and your program called
the Common Language Runtime, or CLR.

2) Once upon a time, not so long ago (but before C# was around), writing programs was harder,
because you had to deal with hardware and low-level machine stuff.

3) The CLR—often referred to as a virtual machine—takes care of all that for you by doing a sort of “translation” between your program and the computer running it.

Tuesday, April 1, 2014

How C# program executes


When you select “Build Solution” from the Build menu, the IDE
compiles your program. It does this by running the compiler, which
is a tool that reads your program’s source code and turns it into an
executable. The executable is a file on your disk that ends in .exe—
that’s what you double-click on to run your program. When you build
the program, it creates the executable inside the bin folder, which is
inside the project folder. When you publish your solution, it copies
the executable (and any other files necessary) into the folder you’re
publishing to.