Professional Documents
Culture Documents
01 Handout 1
01 Handout 1
C# Basic Concepts
I. What is C#?
It is an elegant object-oriented language that enables developers to build a variety of secure
and robust applications that run on the .NET Framework.
It can be used to create Windows applications, Web services, mobile applications, client-
server applications, database applications, and much, much more.
II. Variables
Allows programs to use data for performing tasks.
Reserves a memory location (a space in memory) for storing values.
Information stored in the location can be changed while the program is running, hence its
name.
To use them, they must first be declared by specifying a name and a data type.
o Variable names, also known as identifiers, can contain letters, numbers, and the
underscore character ( _ ); identifiers can only start with a letter or underscore.
o Although the name of a variable can be any set of letters and numbers, the best
identifier is descriptive of the data it will contain; this is very important in order to
create clear, understandable and readable code.
A. Variable Types
Also known as data types.
They define the information that can be stored within a variable, the size of the needed
memory and the operations that can be performed with the variable.
o Console.WriteLine() ends its printed text with a line terminator, which moves the cursor
to the next line; similar subsequent methods will print their text in their own respective
lines.
V. Comments
Explanatory statements that you can include in a program to benefit the reader of your
code.
The compiler ignores everything that appears in the comment, so none of the comment’s
contents affect the result.
A comment beginning with two slashes (//) is called a single-line comment. The slashes
tell the compiler to ignore everything that follows, until the end of the line.
A. Multi-Line Comments
Comments that require multiple lines.
Denoted by the symbols /* at the beginning of the comment block, and end with */ at
the end of the comment block.
They can be placed on the same line or inserted with one or more lines between them.
VII.Constants
Used to store a value that CANNOT be changed after their initial assignment.
Uses the const modifier for its declaration.
Useful for storing values that are unchanging or consistent (such as days of the week, or
the value of pi).
A. Supported Operators
SoloLearn.com
D. Operator Precedence
Determines the grouping of terms in an expression, which affects the sequence in which
an expression is evaluated.
Certain operators take higher precedence over others; for example, the multiplication
operator has higher precedence than the addition operator.
Usage of parentheses (( )) can alter the precedence of operators in any given expression:
Operations within parentheses are performed first; if there are parenthetical expressions
nested within one another, the expression within the innermost parentheses is evaluated
first.
Operator precedence in programming follows the same rules of precedence in general
mathematics.
A. Assignment Operators
Assigns the value on the right side of the operator to the variable on the left side.
Denoted by the equal sign (=).
C# also provides Compound Assignment Operators that perform an operation and an
assignment in one statement; this is usually done by adding the appropriate arithmetic
operator before the equal sign.
References:
SoloLearn. (n.d.). C# tutorial. Retrieved from https://www.sololearn.com/Course/CSharp/
Microsoft (n.d.). Introducing Visual Studio.NET. Retrieved May 2016 from
http://msdn.microsoft.com/en-uslibrary/fc6bk1f4(v=vs.71).aspx.