Chapter 2


Chapter 2
Working with Variables, Operators, and Expressions
After completing this chapter, you will be able to:
  • Understand statements, identifiers, and keywords.

  • Use variables to store information.

  • Work with primitive data types.

  • Use arithmetic operators such as the plus sign (+) and the minus sign (–).

  • Increment and decrement variables.

In Chapter 1, “Welcome to C# 2005,” you learned how to use the Microsoft Visual Studio 2005 programming environment to build and run a console program and a Windows Forms application. In this chapter, you'll be introduced to the elements of Microsoft Visual C# 2005 syntax and semantics, including statements, keywords, and identifiers. You'll study the primitive types that are built into the C# 2005 language and the characteristics of the values that each type holds. You'll also see how to declare and use local variables (variables that exist only within a function or other small section of code), learn about the arithmetic operators that C# 2005 provides, learn how to use operators to manipulate values, and learn how to control expressions containing two or more operators.

the following is :

Chapter 2 Quick Reference

To

Do this

Declare a variable

Write the name of the data type, followed by the name of the variable, followed by a semicolon. For example:

int outcome;

Change the value of a variable

Write the name of the variable on the left, followed by the assignment operator, followed by the expression calculating the new value, followed by a semicolon. For example:

outcome = 42;

Convert a string to an int

Call the System.Int32.Parse method. For example:

System.Int32.Parse("42");

Override precedence

Use parentheses in the expression to force operands to bind to specific operators. For example:

(3 + 4) * 5

Increment or decrement a variable

Use the ++ or <;$MI><;$MI> operator. For example:

count++;


count = count + 1;
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值