Variables and Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Objectives • Understand how to create variables and assign values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Objectives • Understand how to create variables and assign values • Review the available data types and how they are based on the .NET Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Objectives • Understand how to create variables and assign values • Review the available data types and how they are based on the .NET Framework • See how to convert a variable from one data type to another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Objectives • Understand how to create variables and assign values • Review the available data types and how they are based on the .NET Framework • See how to convert a variable from one data type to another • Explore operators and how they can be used to change values and compare expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type  Name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type  Name  Value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must  Begin with an alphabetic character or an underscore Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore  Be less than 1,023 characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Naming Variables • Variable names must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore  Be less than 1,023 characters • Variable names should be descriptive and of reasonable length Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables • Use the Dim keyword to declare a variable and allocate storage space for it in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables • Use the Dim keyword to declare a variable and allocate storage space for it in memory • Use the As clause to specify the variable’s data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables • Use the Dim keyword to declare a variable and allocate storage space for it in memory • Use the As clause to specify the variable’s data type Dim counter1 As Integer Dim counter2 As Integer = 612 Dim message1, message2, message3 As String message2 = "" message3 = "Hello" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables • To declare a variable and allocate storage space for it in memory, first specify the data type and then specify the variable’s name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Declaring Variables • To declare a variable and allocate storage space for it in memory, first specify the data type and then specify the variable’s name int counter1; int counter2 = 612; string message1, message2, message3; message2 = ""; message3 = "Hello"; Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope • Variable’s lifetime is length of time it is available Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it  Variable declared in a procedure method will be available only to that procedure method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Variable Lifetime and Scope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it  Variable declared in a procedure method will be available only to that procedure method  Declare a variable at the class module level for it to be available to multiple procedures methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Data Types • All information has a type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Data Types • All information has a type • Type defines how information will be stored, used, manipulated, and displayed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Data Types • All information has a type • Type defines how information will be stored, used, manipulated, and displayed • .NET Framework contains structures and classes that represent various types of data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Data Types • All information has a type • Type defines how information will be stored, used, manipulated, and displayed • .NET Framework contains structures and classes that represent various types of data • All data types in Visual Basic and C# are based on a .NET Framework structure or class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 • UShort – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 • UShort – based on System.Int16  16-bit unsigned integer between 0 and 65,535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 • ULong – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 • ushort – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 • ushort – based on System.Int16  16-bit unsigned integer between 0 and 65,535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types • int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 • ulong – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes)  Integer and Long are more efficient than Byte or Short because .NET Framework represents numbers as 32-bit or 64-bit values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes)  Integer and Long are more efficient than Byte or Short because .NET Framework represents numbers as 32-bit or 64-bit values • Use Integer unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes)  int and long are more efficient than Byte or short because .NET Framework represents numbers as 32- bit or 64-bit values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Choosing an Integer Data Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes)  int and long are more efficient than Byte or short because .NET Framework represents numbers as 32- bit or 64-bit values • Use int unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Fields and Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Fields and Methods • MinValue and MaxValue represent low and high end of range of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Fields and Methods • MinValue and MaxValue represent low and high end of range of values • ToString returns string representation of value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Integer Data Types Fields and Methods • MinValue and MaxValue represent low and high end of range of values • ToString returns string representation of value  Specify format to control how string is displayed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • Single – based on System.Single Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values • Use Double unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • float – based on System.Single Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Floating-Point Data Types • float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values • Use double unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type • Based on System.Decimal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type • Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type • Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places • Holds numbers of lesser magnitude than floating points, but with greater precision Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type • Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places • Holds numbers of lesser magnitude than floating points, but with greater precision • Use when you need the utmost in precision, Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Fields and Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Fields and Methods • Truncate returns integer part and discards fractional part Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Fields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Fields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places • Floor rounds to integer smaller than or equal to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Decimal Data Type Fields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places • Floor rounds to integer smaller than or equal to the value • Ceiling rounds to integer greater than or equal to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type • Based on System.Char Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type • Based on System.Char  16-bit numeric value between 0 to 65535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type • Based on System.Char  16-bit numeric value between 0 to 65535 • Holds code points, or character codes, representing a single Unicode character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type • Based on System.Char  16-bit numeric value between 0 to 65535 • Holds code points, or character codes, representing a single Unicode character  The first 128 code points, numbers 0 through 127, are the ASCII character set Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • ConvertFromUtf32 returns Unicode character associated with code point Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • ConvertFromUtf32 returns Unicode character associated with code point • ConvertToUtf32 returns code point associated with Unicode character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark • IsSeparator indicates if a separator, such as a space Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Char Data Type Methods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark • IsSeparator indicates if a separator, such as a space • IsSymbol indicates if a symbol, such as a + or - Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters • To include quotation marks in a string, use two in a row Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters • To include quotation marks in a string, use two in a row  Dim greeting As String = "Hello ""Robert""" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Boolean Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Boolean Data Type • Based on System.Boolean Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Boolean Data Type • Based on System.Boolean  0 (True) or 1 (False) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Boolean Data Type • Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Boolean Data Type • Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions If firstVariable > secondVariable Then Console.WriteLine("{0} is greater than {1}", _ firstVariable, secondVariable) End If Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# • Must use M/d/yyyy format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Date Data Type • Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# • Must use M/d/yyyy format • Consider using DateTime rather than Date Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters • Use escape sequence () or preface the string with @ to include quotation marks and backslashes in strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Data Type • Based on System.String  Represents a series of 0 to 2 billion characters • Use escape sequence () or preface the string with @ to include quotation marks and backslashes in strings  string greeting1 = "Hello " Robert""; string greeting2 = @"Hello "" Robert"""; Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Bool Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Bool Data Type • Based on System.Boolean Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Bool Data Type • Based on System.Boolean  0 (True) or 1 (False) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Bool Data Type • Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Bool Data Type • Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions if (firstVariable > secondVariable) { Console.WriteLine("{0} is greater than {1}", firstVariable, secondVariable); } Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Object Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Object Data Type • Based on System.Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Object Data Type • Based on System.Object • Can contain any data type, including another object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Object Data Type • Based on System.Object • Can contain any data type, including another object • Use GetType to determine what type of data is stored Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Object Data Type • Based on System.Object • Can contain any data type, including another object • Use GetType to determine what type of data is stored • Contains a pointer to the value in memory, not actual data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another • Constants, Enumerations, and Structures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another • Constants, Enumerations, and Structures • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result  Need to make the conversion in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result  Need to make the conversion in code • Make your conversions explicitly in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) • Parse method converts a string to a data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) • Parse method converts a string to a data type  Single.Parse(longValue.ToString()) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); • Parse method converts a string to a data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Converting to Another Data Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); • Parse method converts a string to a data type  Single.Parse(longValue.ToString()); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Value type variables directly store their values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types  Declared in code and runtime allocates proper amount of memory for them Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types  Declared in code and runtime allocates proper amount of memory for them  Efficient because space has already been allocated on stack Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Reference type variables store a reference to their values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value  Reference is used to find a value each time a variable is accessed in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value  Reference is used to find a value each time a variable is accessed in code  Less efficient than value types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing  A value type is converted to a reference type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing  A reference type is converted to a value type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Value Types and Reference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing  A reference type is converted to a value type  NET Framework uses the reference to copy the value back into a value type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Constants Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Constants • Declared like variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Constants • Declared like variables • Value cannot be changed in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Enumerations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Enumerations • Collection of related constants Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Enumerations • Collection of related constants • Has a name and a numeric data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Enumerations • Collection of related constants • Has a name and a numeric data type • Has a number of fields, each with a name and a value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structures • Structures are user-defined data types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structures • Structures are user-defined data types • Similar to enumerations in that they are a collection of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structures • Structures are user-defined data types • Similar to enumerations in that they are a collection of values • Can contain any data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structs Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structs • Structs are user-defined data types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structs • Structs are user-defined data types • Similar to enumerations in that they are a collection of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Structs • Structs are user-defined data types • Similar to enumerations in that they are a collection of values • Can contain any data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators  String operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators  Logical operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Operators • Perform an action on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators  Logical operators  Type operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result  divides two numbers and returns only the integer part of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result  divides two numbers and returns only the integer part of the result  ^ raises a number to the power of another number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character  Use a # in the pattern to match to any single digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • & and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character  Use a # in the pattern to match to any single digit  Use a [] in the pattern to match to a list of Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers  = divides two numbers and returns only the integer part of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal  <> returns true if two values are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second  <= returns true if the first value is less than or equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true.  A Is B returns true if A and B refer to the same object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true.  A Is B returns true if A and B refer to the same object  A IsNot B returns true if A and B do not refer to the same Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators • Test whether an object is of a particular data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators • Test whether an object is of a particular data type Dim object1 As Object object1 = 7 If TypeOf object1 Is Integer Then Console.WriteLine("object1 = 7 and is type Integer") End If Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  % divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Arithmetic Operators • Perform basic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  % divides two numbers and returns only the remainder of the result  ++ increments a number by 1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
String Operators • + operator concatenates, or adds, two strings together to produce a new string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Assignment Operators • Perform similar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers  %= divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal  != returns true if two values are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Comparison Operators • Used to compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second  <= returns true if the first value is less than or equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true  A && B returns true if both A and B are true. Does not evaluate B if A is not true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Logical Operators • Used to compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true  A && B returns true if both A and B are true. Does not evaluate B if A is not true.  A || B returns true if either A or B is true. Does not evaluate B if A is true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators • Test whether an object is of a particular data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Type Operators • Test whether an object is of a particular data type object object1; object1 = 7; if (object1 is int) { Console.WriteLine("object1 = 7 and is type Integer"); } Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about .NET on SlideShare: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about .NET on SlideShare: • Getting Started with .NET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

.NET Variables and Data Types

  • 1.
    Variables and DataTypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2.
    Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3.
    Objectives • Understand howto create variables and assign values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4.
    Objectives • Understand howto create variables and assign values • Review the available data types and how they are based on the .NET Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5.
    Objectives • Understand howto create variables and assign values • Review the available data types and how they are based on the .NET Framework • See how to convert a variable from one data type to another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6.
    Objectives • Understand howto create variables and assign values • Review the available data types and how they are based on the .NET Framework • See how to convert a variable from one data type to another • Explore operators and how they can be used to change values and compare expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7.
    Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8.
    Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9.
    Agenda • Variables • DataTypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11.
    Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12.
    Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13.
    Variables • Computer programsmanage information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14.
    Variables • Computer programsmanage information • Variables are a way to store information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15.
    Variables • Computer programsmanage information • Variables are a way to store information • Variables exist in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16.
    Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17.
    Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18.
    Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19.
    Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type  Name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20.
    Variables • Computer programs manage information • Variables are a way to store information • Variables exist in memory • Created at the start of programs or as needed • Variables have three components  Data type  Name  Value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21.
    Naming Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22.
    Naming Variables • Variablenames must Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23.
    Naming Variables • Variablenames must  Begin with an alphabetic character or an underscore Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24.
    Naming Variables • Variablenames must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25.
    Naming Variables • Variablenames must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26.
    Naming Variables • Variablenames must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore  Be less than 1,023 characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27.
    Naming Variables • Variablenames must  Begin with an alphabetic character or an underscore  Contain only alphabetic characters, numbers, and underscores  Contain at least one alphabetic character or number if they begin with an underscore  Be less than 1,023 characters • Variable names should be descriptive and of reasonable length Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28.
    Declaring Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29.
    Declaring Variables • Usethe Dim keyword to declare a variable and allocate storage space for it in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30.
    Declaring Variables • Usethe Dim keyword to declare a variable and allocate storage space for it in memory • Use the As clause to specify the variable’s data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31.
    Declaring Variables • Usethe Dim keyword to declare a variable and allocate storage space for it in memory • Use the As clause to specify the variable’s data type Dim counter1 As Integer Dim counter2 As Integer = 612 Dim message1, message2, message3 As String message2 = "" message3 = "Hello" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32.
    Declaring Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33.
    Declaring Variables • Todeclare a variable and allocate storage space for it in memory, first specify the data type and then specify the variable’s name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34.
    Declaring Variables • Todeclare a variable and allocate storage space for it in memory, first specify the data type and then specify the variable’s name int counter1; int counter2 = 612; string message1, message2, message3; message2 = ""; message3 = "Hello"; Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35.
    Variable Lifetime andScope Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36.
    Variable Lifetime andScope • Variable’s lifetime is length of time it is available Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37.
    Variable Lifetime andScope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38.
    Variable Lifetime andScope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39.
    Variable Lifetime andScope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it  Variable declared in a procedure method will be available only to that procedure method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40.
    Variable Lifetime andScope • Variable’s lifetime is length of time it is available  Variable declared in a procedure method will be in memory as long as that procedure method exists • Variable’s scope determines what code can reference it  Variable declared in a procedure method will be available only to that procedure method  Declare a variable at the class module level for it to be available to multiple procedures methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41.
    Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42.
    Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43.
    Agenda • Variables • DataTypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45.
    Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46.
    Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47.
    Data Types • Allinformation has a type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48.
    Data Types • Allinformation has a type • Type defines how information will be stored, used, manipulated, and displayed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49.
    Data Types • Allinformation has a type • Type defines how information will be stored, used, manipulated, and displayed • .NET Framework contains structures and classes that represent various types of data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50.
    Data Types • Allinformation has a type • Type defines how information will be stored, used, manipulated, and displayed • .NET Framework contains structures and classes that represent various types of data • All data types in Visual Basic and C# are based on a .NET Framework structure or class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51.
    Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52.
    Integer Data Types •SByte – based on System.SByte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 • UShort – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59.
    Integer Data Types •SByte – based on System.SByte  Signed 8-bit integer between -128 and 127 • Byte – based on System.Byte  8-bit integer between 0 and 255 • Short – based on System.Int16  16-bit integer between -32,768 and 32,767 • UShort – based on System.Int16  16-bit unsigned integer between 0 and 65,535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60.
    Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61.
    Integer Data Types •Integer – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67.
    Integer Data Types •Integer – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • UInteger – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • Long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 • ULong – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68.
    Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69.
    Integer Data Types •sbyte – based on System.SByte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 74.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 75.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 • ushort – based on System.Int16 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 76.
    Integer Data Types •sbyte – based on System.SByte  Signed 8-bit integer between -128 and 127 • byte – based on System.Byte  8-bit integer between 0 and 255 • short – based on System.Int16  16-bit integer between -32,768 and 32,767 • ushort – based on System.Int16  16-bit unsigned integer between 0 and 65,535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 77.
    Integer Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 78.
    Integer Data Types •int – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 79.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 80.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 81.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 82.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 83.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 84.
    Integer Data Types •int – based on System.Int32  32-bit integer between -2,147,483,648 and 2,147,483,647 • uint – based on System.Int32  32-bit unsigned integer between 0 and 4,294,967,295 • long – based on System.Int64  64-bit integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 • ulong – based on System.Int64 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 85.
    Choosing an IntegerData Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 86.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 87.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 88.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 89.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes)  Integer and Long are more efficient than Byte or Short because .NET Framework represents numbers as 32-bit or 64-bit values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 90.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  Integer requires twice as much storage space (4 bytes) than Short (2 bytes)  Integer and Long are more efficient than Byte or Short because .NET Framework represents numbers as 32-bit or 64-bit values • Use Integer unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 91.
    Choosing an IntegerData Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 92.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 93.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 94.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 95.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes)  int and long are more efficient than Byte or short because .NET Framework represents numbers as 32- bit or 64-bit values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 96.
    Choosing an IntegerData Type • Choose a data type that is appropriate for the data you will store • Balance memory requirement and performance  int requires twice as much storage space (4 bytes) than short (2 bytes)  int and long are more efficient than Byte or short because .NET Framework represents numbers as 32- bit or 64-bit values • Use int unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 97.
    Integer Data TypesFields and Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 98.
    Integer Data TypesFields and Methods • MinValue and MaxValue represent low and high end of range of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 99.
    Integer Data TypesFields and Methods • MinValue and MaxValue represent low and high end of range of values • ToString returns string representation of value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 100.
    Integer Data TypesFields and Methods • MinValue and MaxValue represent low and high end of range of values • ToString returns string representation of value  Specify format to control how string is displayed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 101.
    Floating-Point Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 102.
    Floating-Point Data Types •Single – based on System.Single Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 103.
    Floating-Point Data Types •Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 104.
    Floating-Point Data Types •Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 105.
    Floating-Point Data Types •Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 106.
    Floating-Point Data Types •Single – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • Double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values • Use Double unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 107.
    Floating-Point Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 108.
    Floating-Point Data Types •float – based on System.Single Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 109.
    Floating-Point Data Types •float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 110.
    Floating-Point Data Types •float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 111.
    Floating-Point Data Types •float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 112.
    Floating-Point Data Types •float – based on System.Single  32-bit single-precision floating point number between -3.402823 x 1038 and -1.401298 / 1045 for negative values and 1.401298 / 1045 and 3.402823 x 1038 for positive values • double – based on System.Double  64-bit double-precision floating point number between -1.79769313486231570 x 10308 and -4.94065645841246544 / 10324 for negative values and between 4.94065645841246544 x 10324 and 1.79769313486231570 x 10308 for positive values • Use double unless you have valid concerns about memory usage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 113.
    Decimal Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 114.
    Decimal Data Type •Based on System.Decimal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 115.
    Decimal Data Type •Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 116.
    Decimal Data Type •Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places • Holds numbers of lesser magnitude than floating points, but with greater precision Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 117.
    Decimal Data Type •Based on System.Decimal  128-bit number between -79,228,162,514,264,337,593,543,950,335 and 79,228,162,514,264,337,593,543,950,335 with no decimal places and between -7.9228162514264337593543950335 and 7.9228162514264337593543950335 with up to 28 decimal places • Holds numbers of lesser magnitude than floating points, but with greater precision • Use when you need the utmost in precision, Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 118.
    Decimal Data TypeFields and Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 119.
    Decimal Data TypeFields and Methods • Truncate returns integer part and discards fractional part Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 120.
    Decimal Data TypeFields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 121.
    Decimal Data TypeFields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places • Floor rounds to integer smaller than or equal to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 122.
    Decimal Data TypeFields and Methods • Truncate returns integer part and discards fractional part • Round rounds to nearest integer or to a specified number of decimal places • Floor rounds to integer smaller than or equal to the value • Ceiling rounds to integer greater than or equal to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 123.
    Char Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 124.
    Char Data Type •Based on System.Char Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 125.
    Char Data Type •Based on System.Char  16-bit numeric value between 0 to 65535 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 126.
    Char Data Type •Based on System.Char  16-bit numeric value between 0 to 65535 • Holds code points, or character codes, representing a single Unicode character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 127.
    Char Data Type •Based on System.Char  16-bit numeric value between 0 to 65535 • Holds code points, or character codes, representing a single Unicode character  The first 128 code points, numbers 0 through 127, are the ASCII character set Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 128.
    Char Data TypeMethods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 129.
    Char Data TypeMethods • ConvertFromUtf32 returns Unicode character associated with code point Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 130.
    Char Data TypeMethods • ConvertFromUtf32 returns Unicode character associated with code point • ConvertToUtf32 returns code point associated with Unicode character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 131.
    Char Data TypeMethods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 132.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 133.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 134.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 135.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 136.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 137.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 138.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 139.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark • IsSeparator indicates if a separator, such as a space Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 140.
    Char Data TypeMethods • IsControl indicates if a tab, carriage return, or line feed • IsDigit indicates if a decimal digit • IsLetter indicates if an alphabetic letter • IsLetterOrDigit indicates if a letter or digit • IsLower indicates if a lowercase letter • IsNumber indicates if a number • IsPunctuation indicates if a punctuation mark • IsSeparator indicates if a separator, such as a space • IsSymbol indicates if a symbol, such as a + or - Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 141.
    String Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 142.
    String Data Type •Based on System.String Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 143.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 144.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters • To include quotation marks in a string, use two in a row Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 145.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters • To include quotation marks in a string, use two in a row  Dim greeting As String = "Hello ""Robert""" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 146.
    Boolean Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 147.
    Boolean Data Type •Based on System.Boolean Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 148.
    Boolean Data Type •Based on System.Boolean  0 (True) or 1 (False) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 149.
    Boolean Data Type •Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 150.
    Boolean Data Type •Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions If firstVariable > secondVariable Then Console.WriteLine("{0} is greater than {1}", _ firstVariable, secondVariable) End If Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 151.
    Date Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 152.
    Date Data Type •Based on System.DateTime Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 153.
    Date Data Type •Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 154.
    Date Data Type •Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 155.
    Date Data Type •Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 156.
    Date Data Type •Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# • Must use M/d/yyyy format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 157.
    Date Data Type •Based on System.DateTime  64 bit values representing dates ranging from 01/01/0001 through 12/31/9999 and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM • Enclose the date within # characters  Dim nextCentury As Date = #1/1/2100# • Must use M/d/yyyy format • Consider using DateTime rather than Date Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 158.
    String Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 159.
    String Data Type •Based on System.String Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 160.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 161.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters • Use escape sequence () or preface the string with @ to include quotation marks and backslashes in strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 162.
    String Data Type •Based on System.String  Represents a series of 0 to 2 billion characters • Use escape sequence () or preface the string with @ to include quotation marks and backslashes in strings  string greeting1 = "Hello " Robert""; string greeting2 = @"Hello "" Robert"""; Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 163.
    Bool Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 164.
    Bool Data Type •Based on System.Boolean Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 165.
    Bool Data Type •Based on System.Boolean  0 (True) or 1 (False) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 166.
    Bool Data Type •Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 167.
    Bool Data Type •Based on System.Boolean  0 (True) or 1 (False) • Used to test conditions if (firstVariable > secondVariable) { Console.WriteLine("{0} is greater than {1}", firstVariable, secondVariable); } Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 168.
    Object Data Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 169.
    Object Data Type •Based on System.Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 170.
    Object Data Type •Based on System.Object • Can contain any data type, including another object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 171.
    Object Data Type •Based on System.Object • Can contain any data type, including another object • Use GetType to determine what type of data is stored Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 172.
    Object Data Type •Based on System.Object • Can contain any data type, including another object • Use GetType to determine what type of data is stored • Contains a pointer to the value in memory, not actual data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 173.
    Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 174.
    Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 175.
    Agenda • Variables • DataTypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 176.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 177.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another • Constants, Enumerations, and Structures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 178.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another • Constants, Enumerations, and Structures • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 179.
    Converting to AnotherData Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 180.
    Converting to AnotherData Type • Widening conversion Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 181.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 182.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 183.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 184.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 185.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 186.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result  Need to make the conversion in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 187.
    Converting to AnotherData Type • Widening conversion  New data type can store all of the values of the original data type  Compiler will make the conversion for you • Narrowing conversion  New data type cannot store all of the values of the original data type  Loss of data could result  Need to make the conversion in code • Make your conversions explicitly in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 188.
    Converting to AnotherData Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 189.
    Converting to AnotherData Type • Use a conversion function Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 190.
    Converting to AnotherData Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 191.
    Converting to AnotherData Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 192.
    Converting to AnotherData Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 193.
    Converting to AnotherData Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) • Parse method converts a string to a data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 194.
    Converting to AnotherData Type • Use a conversion function  shortValue = shortValue + CShort(byteValue) • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue) • Parse method converts a string to a data type  Single.Parse(longValue.ToString()) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 195.
    Converting to AnotherData Type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 196.
    Converting to AnotherData Type • Use a cast operator Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 197.
    Converting to AnotherData Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 198.
    Converting to AnotherData Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 199.
    Converting to AnotherData Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 200.
    Converting to AnotherData Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); • Parse method converts a string to a data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 201.
    Converting to AnotherData Type • Use a cast operator  shortValue = (short)(shortValue + byteValue); • Convert class includes a conversion method for each data type  Convert.ToSingle(longValue); • Parse method converts a string to a data type  Single.Parse(longValue.ToString()); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 202.
    Value Types andReference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 203.
    Value Types andReference Types • Value type variables directly store their values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 204.
    Value Types andReference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 205.
    Value Types andReference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types  Declared in code and runtime allocates proper amount of memory for them Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 206.
    Value Types andReference Types • Value type variables directly store their values  Stored in the stack, pool of memory allocated by runtime for value types  Declared in code and runtime allocates proper amount of memory for them  Efficient because space has already been allocated on stack Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 207.
    Value Types andReference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 208.
    Value Types andReference Types • Reference type variables store a reference to their values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 209.
    Value Types andReference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 210.
    Value Types andReference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 211.
    Value Types andReference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value  Reference is used to find a value each time a variable is accessed in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 212.
    Value Types andReference Types • Reference type variables store a reference to their values  Stored in the heap, a pool of memory whose size is dynamic  Value is stored in the stack, but variable stores a reference to a value  Reference is used to find a value each time a variable is accessed in code  Less efficient than value types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 213.
    Value Types andReference Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 214.
    Value Types andReference Types • Boxing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 215.
    Value Types andReference Types • Boxing  A value type is converted to a reference type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 216.
    Value Types andReference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 217.
    Value Types andReference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 218.
    Value Types andReference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing  A reference type is converted to a value type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 219.
    Value Types andReference Types • Boxing  A value type is converted to a reference type  .NET Framework copies the value to the heap and returns a reference to the value • Unboxing  A reference type is converted to a value type  NET Framework uses the reference to copy the value back into a value type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 220.
    Constants Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 221.
    Constants • Declared likevariables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 222.
    Constants • Declared likevariables • Value cannot be changed in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 223.
    Enumerations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 224.
    Enumerations • Collection ofrelated constants Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 225.
    Enumerations • Collection ofrelated constants • Has a name and a numeric data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 226.
    Enumerations • Collection ofrelated constants • Has a name and a numeric data type • Has a number of fields, each with a name and a value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 227.
    Structures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 228.
    Structures • Structures areuser-defined data types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 229.
    Structures • Structures areuser-defined data types • Similar to enumerations in that they are a collection of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 230.
    Structures • Structures areuser-defined data types • Similar to enumerations in that they are a collection of values • Can contain any data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 231.
    Structs Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 232.
    Structs • Structs areuser-defined data types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 233.
    Structs • Structs areuser-defined data types • Similar to enumerations in that they are a collection of values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 234.
    Structs • Structs areuser-defined data types • Similar to enumerations in that they are a collection of values • Can contain any data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 235.
    Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 236.
    Agenda • Variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 237.
    Agenda • Variables • DataTypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 238.
    Agenda • Variables • DataTypes • Converting from One Data Type to Another Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 239.
    Agenda • Variables • Data Types • Converting from One Data Type to Another • Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 240.
    Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 241.
    Operators • Perform anaction on one or more values and return the result of the operation Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 242.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 243.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators  String operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 244.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 245.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 246.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators  Logical operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 247.
    Operators • Perform anaction on one or more values and return the result of the operation  Arithmetic operators  String operators  Assignment operators  Comparison operators  Logical operators  Type operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 248.
    Arithmetic Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 249.
    Arithmetic Operators • Performbasic arithmetic on one or more variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 250.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 251.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 252.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 253.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 254.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 255.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result  divides two numbers and returns only the integer part of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 256.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  Mod divides two numbers and returns only the remainder of the result  divides two numbers and returns only the integer part of the result  ^ raises a number to the power of another number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 257.
    String Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 258.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 259.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 260.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 261.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 262.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character  Use a # in the pattern to match to any single digit Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 263.
    String Operators • &and + operators concatenate, or add, two strings together to produce a new string • Use Like to determine if a string matches a pattern  Use a * in the pattern to match to zero or more characters  Use a ? in the pattern to match to any single character  Use a # in the pattern to match to any single digit  Use a [] in the pattern to match to a list of Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 264.
    Assignment Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 265.
    Assignment Operators • Performsimilar operations as arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 266.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 267.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 268.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 269.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 270.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers  = divides two numbers and returns only the integer part of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 271.
    Comparison Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 272.
    Comparison Operators • Usedto compare two values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 273.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 274.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal  <> returns true if two values are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 275.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 276.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 277.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 278.
    Comparison Operators • Usedto compare two values  = returns true if two values are equal  <> returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second  <= returns true if the first value is less than or equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 279.
    Logical Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 280.
    Logical Operators • Usedto compare two expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 281.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 282.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 283.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 284.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 285.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 286.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 287.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true.  A Is B returns true if A and B refer to the same object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 288.
    Logical Operators • Usedto compare two expressions  A And B returns true if both A and B are true  A Or B returns true if either A or B is true  Not A returns true if A is not true  A Xor B returns true if either A or B is true, but both of them are not true  A AndAlso B returns true if both A and B are true. Does not evaluate B if A is not true.  A OrElse B returns true if either A or B is true. Does not evaluate B if A is true.  A Is B returns true if A and B refer to the same object  A IsNot B returns true if A and B do not refer to the same Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 289.
    Type Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 290.
    Type Operators • Testwhether an object is of a particular data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 291.
    Type Operators • Testwhether an object is of a particular data type Dim object1 As Object object1 = 7 If TypeOf object1 Is Integer Then Console.WriteLine("object1 = 7 and is type Integer") End If Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 292.
    Arithmetic Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 293.
    Arithmetic Operators • Performbasic arithmetic on one or more variables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 294.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 295.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 296.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 297.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 298.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  % divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 299.
    Arithmetic Operators • Performbasic arithmetic on one or more variables  + adds two numbers or converts a negative number into a positive number  - subtracts two numbers or converts a positive number into a negative number  * multiplies two numbers  / divides two numbers  % divides two numbers and returns only the remainder of the result  ++ increments a number by 1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 300.
    String Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 301.
    String Operators • +operator concatenates, or adds, two strings together to produce a new string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 302.
    Assignment Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 303.
    Assignment Operators • Performsimilar operations as arithmetic operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 304.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 305.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 306.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 307.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 308.
    Assignment Operators • Performsimilar operations as arithmetic operators  += adds two numbers or converts a negative number into a positive number  -= subtracts two numbers or converts a positive number into a negative number  *= multiplies two numbers  /= divides two numbers  %= divides two numbers and returns only the remainder of the result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 309.
    Comparison Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 310.
    Comparison Operators • Usedto compare two values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 311.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 312.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal  != returns true if two values are not equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 313.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 314.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 315.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 316.
    Comparison Operators • Usedto compare two values  == returns true if two values are equal  != returns true if two values are not equal  > returns true if the first value is greater than the second  < returns true if the first value is less than the second  >= returns true if the first value is greater than or equal to the second  <= returns true if the first value is less than or equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 317.
    Logical Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 318.
    Logical Operators • Usedto compare two expressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 319.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 320.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 321.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 322.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 323.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true  A && B returns true if both A and B are true. Does not evaluate B if A is not true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 324.
    Logical Operators • Usedto compare two expressions  A & B returns true if both A and B are true  A | B returns true if either A or B is true  ! A returns true if A is not true  A ^ B returns true if either A or B is true but both of them are not true  A && B returns true if both A and B are true. Does not evaluate B if A is not true.  A || B returns true if either A or B is true. Does not evaluate B if A is true. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 325.
    Type Operators Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 326.
    Type Operators • Testwhether an object is of a particular data type Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 327.
    Type Operators • Testwhether an object is of a particular data type object object1; object1 = 7; if (object1 is int) { Console.WriteLine("object1 = 7 and is type Integer"); } Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 328.
    Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 329.
    Learn More! • Thisis an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 330.
    Learn More! • Thisis an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 331.
    Learn More! • Thisis an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about .NET on SlideShare: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 332.
    Learn More! • Thisis an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about .NET on SlideShare: • Getting Started with .NET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Editor's Notes