Está en la página 1de 19

Numeric String and Data

Built-in Value Types

Declare and Initialize Variables


A variable stores a value that can change as the

program executes Declare and initialize a variable in one statement or assign a value immediately after you declare it Use camel notation as programming convention Example:

type variableName; variableName=value;

Declare and Initialize Constants


A constant stores a value that cant be changed as the

program executes Example:

const type ConstantName=value;

Naming Conventions
Start the names of variables with a lowercase letter ,

and capitalize the first letter of each word after first word, also called Camel Notation Capitalize the first letter of each word of a constant name, also called Pascal Notation

Arithmetic Expressions

Arithmetic Expression
An arithmetic expression consists of one or more

operands and arithmetic operators The first five binary operators above are called binary operators because they operate on two operands . The next four are called unary operators because they operate because they operate on just one operand

Assignment Operators

Order of Precedence
Increment and decrement 2. Positive and negative 3. Multiplication, division , and modulus 4. Addition and subtraction
1.

Math Class
Round method: Math.Round (decimalNumber[,precision]) Pow method Math.Pow(number, power) Sqrt method Math.Sqrt(number) Min and Max methods Math.{Min/Max}(number1,number2)

Strings
A string can consist of any character including

symbols String literal-value of string in closed quotes Null value-value of string is unknown Empty string-string with no value inside closed quotes Concatenation-join strings, uses the + sign Append-adding one string to another, += string is used

Escape sequences
\n new line

\t tab
\r carriage return \\ - backlash

\ - quotation

.NET structures and data types

.NET structures and data types


Each built in data type is supported by a structure or

a class within the .NET framework. When you use a C# keyword to refer to a data type , youre actually using an alias associated structure or class A structure define a value type which stores its own data A class defines a reference type. A referenced type doesnt store and data itself. Instead, it stores a reference to the area of memory where data is stored All structures and classes shown are in the System namespace

Common methods for data conversion

Some of the static methods of the convert class

Standard numeric formatting codes

How to use the ToString method to format a number

How to use the Format method of the String class to format a number

También podría gustarte