VB.NET Datatypes.pptx

SubashiniRathinavel 427 views 16 slides Apr 10, 2022
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

VB.NET Data types


Slide Content

Visual Basic .Net - Chapter 3

Data Types Value types - Stored on the stack Integer, Long, Short, Byte, Single, Double, Decimal, Char, Boolean, Structure, Enum Reference types - Stored on the heap Object, Class, Interface, Delegate, String, Array

Variable Declaration and Initialization The entities that can be assigned different values duting the execution of a program are known as variables. It refers to the memory locations in whcih the values assigned to them are stored Smallest textual element in a program that cannot be further reduced is called token. Identifiers are tokens that are designed by the programmers

Rules for identifiers It can contain digits, alphabets, and the underscore character First character should not be a digit VB.NET keywords should not be used as identifiers. But a keyword can also be used as identifier if it is prefixed with the @ character VB.NET is not case sensitive

Variable declaration Dim a as integer Dim a as integer = 100 Option Explicit Off Dim s1 As Sample = new Sample()

Value Data types - Integer Byte(unsigned) - 8 bits - 0 to 255 byte(signed) - 8 bits - 128 to 127 short(signed) - 16 bits - -32,768 to 32,767 ushort(unsigned) - 16 bits - 0 to 65,535 uint(unsigned) - 32 bits - 0 to 4,294,967,295 ulong(unsigned) - 64 bits - 0 to 18,446,744,073,709,551,615 int (signed) - 32 bits - -2,147,483,648 to 2,147,483,647 long(signed) - 64 bits - -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807

Value Data types Single - Number with fractional part with 6 digits of accuracy - 32 bits - -3.40 * 10 ^ 38 to 3.40 * 10 ^ 38 Double - Number with fractional part with 14 digits of accuracy - 64 bits - -1.79 * 10 ^ 308 to 1.79 * 10 ^ 308 Char - Single unicode character - 2 bytes - Backslash character or Escape sequences Boolean type - True or false - 16 bits

Structure type - Composite data types Public structure st Dim x as integer Dim y as integer End structure Dim p as st st.x=20 st.y=30

public structure st public x as integer public y as integer end structure public structure ci public s as st public z as integer end structure Dim ci as c c.s.x=20 c.s.y=30 c.z=40

Enum - Represent a set of name constants Default data type of the named constants is an enum type is int Enum Direction West East North South End Enum Date - Represent a date in the range 1/1/0001 to 12/31/9999

Reference Data types Object, String, Class, Interface, Delegate and Array Instance of a reference type variable is allocated memory on the heap A reference to that instance is created on the stack Object Type - Predefined reference type. Serves as the base class for all predefined and user-defined classes. It supplies many basic methods such as Equals() method and ToString() method to all its subclasses. Every predefined class as well as every user defined class automatically inherits tye characteristics of the object class

String - Predefined reference type. Used to represent alpha-numeric data such as letter, digits and other characters Derived directly from the object class Dim s1 as string =”Welcome” Compare - Compares two strings CompareTo - Compares the given string instance with another instance Concat - Concatenates two or more strings Copy - Copy of a given string

Ends With - Checks whether a specified substring exists at the end of the given string Equals - Checks whether two given strings are equal Index of - Determines the position of the first occurrence of a specified substring in the geiven string Insert - Inserts a specified string at a specified position in the given string Join - Joins two or more strings Substring - Extracts a substring from the given string String Class is immutable

StringBuilder - Another predefined class - Mutable Append - Appends a specified string to the given string Insert - Inserts a string at a specified position int he given string Remove - Removes the specified characters from the given string Replace - Replaces all occurrences of a character with a specified character

Scope of a varible - Visibility - Whether it is accessible only within a part of a program or it is accessible in the entire program Procedure-level variables - Only within the procedure in which it is declared - Local Variables Module-level variables - Declared in the declaration section of a module. Classified as private and public Constants - Special type variables whose value remains the same throughout the execution of a program - Keyword as Const

Boxing and Unboxing Conversion of a value type to a reference type - Boxing Conversion of a reference type to a value type - Unboxing Example1 Dim jas integer =29 Dim obj as object = j Example2 k=ctype(obj,Ineger)
Tags