ADBRITE ads links
You are here: CodeIdol.com > C# > Learning C# 2005 > Csharp Language Fundamentals
Learning C# 2005
| 3.1. Statements
In C#, a complete program instruction is called a statement and each statement ends with a semicolon (;)
. Programs consist of sequences of statements such as:
int myVariable; // a statement
myVar...
|
|
| 3.2. Types
C# is a strongly typed language. That means that every object you create or use in a C# program must have a specific type (e.g., you must declare the object to be an integer or a string or a Dog or a Button). Essentially, the type indic...
|
|
| 3.3. Variables
A variable is an instance of an intrinsic type (such as int) that can hold a value:
int myVariable = 15;
You initialize a variable by writing its type, its identifier, and then assigning a value to that variable.
...
|
|
| 3.4. Definite Assignment
C# requires definite assignment
; that is, variables
must be initialized (or assigned to) before they are "used." To test this rule, change the line that initializes myInt in Example 3-1 to:
int myInt;
Sa...
|
|
| 3.5. Constants
Variables are a powerful tool, but there are times when you want to manipulate a defined value, one whose value you want to ensure remains constant. A constant is like a variable in that it can store a value. However, unlike a va...
|
|
| 3.6. Strings
It is nearly impossible to write a C# program without creating strings
. A string object holds a series of characters.
You declare a string variable using the string keyword much as you would create an instance of any type:
...
|
|
| 3.7. Expressions
Statements that evaluate to a value are called expressions
. You may be surprised how many statements do evaluate to a value. For example, an assignment such as:
myVariable = 57;
is an expression; it evaluates to...
|
|
| 3.8. Whitespace
In the C# language, spaces, tabs, and newlines are considered to be whitespace
(so named because you see only the white of the underlying "page"). Extra whitespace is generally ignored in C# statements. Thus, you can write:
...
|
|
| 3.9. Summary
A complete program instruction is called a statement. Each statement ends with a semicolon (;).All objects, constants, and variables must have a specific type.Most of the intrinsic types are used for working with numeric values. You w...
|
|
| 3.10. Quiz
Question 31.
What values can a bool type have?
Question 32.
What is the difference between an int and an Int32?
Question 33.
Which of the following code statements will compile?
int myInt = 25;
long myLong = myInt...
|
|
You are here: CodeIdol.com > C# > Learning C# 2005 > Csharp Language Fundamentals
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|