Earlier we cam across the following: If you look at the above code, you will notice that the employee class’s constructor has input parameters that are called Firstname, Salary, and Age. But these names are also used as the names of the Employee class’s properties. As a result it can […]Read more »
If you declare (and initialize) a variable within an if-else statement, then that variable’s value will only exist within that if-else statement. However if you want to initialize (i.e. assign a value to) the variable within the if-else statement, but want to make the variable accessible outside the if-else scope, […]Read more »
A enum constant is a special kind of variable that can only take a set number of values, e.g.: The cool thing about this aproach is that VS2013 will recognise the enum constant as type of variable, and hence will offer intellisense, e.g.:
Here is a quick switch statement demo:
Previously in the boolean chapter we saw: We can use a technique called substitution as a shorthand, and simpler way to embed objects in strings. It works by embedding curly-braced-numbers in the string, e.g.: The linux Awk command works in a similar way. Also see: http://msdn.microsoft.com/en-us/library/fk49wtc1%28v=vs.110%29.aspx
booleans are variables that hold true or false.
http://msdn.microsoft.com/en-us/library/ty67wk28.aspx This is a single line if-else statement that also has a builtin “return” statement.
In most case a c# file (aka .cs) will contain several (or hundreds of classes). After you have compiled it into an .exe file and double click on it. c# will need to know which part of the c# code needs to run first. You may some a code block […]Read more »
As mentioned earlier, a method is a block of code that performs a specific task. Methods can require some information in order for it to run. This info has to be provided in the form of an “input parameter” Methods can also output information after it has completed running. This […]Read more »
C# is a object oriented language, and that means that whenever we declare a new variable, we are actually using a class that generates (aka instantiates) that variable for us. Let’s says that somewhere in our program we have the following statement: int MyFavouriteNumber = 7 ; Here we are […]Read more »