Data Types and variables in vb.net

Data type:

It is used to specify the type of value that can be assigned to the member.

 

Note:

VB.Net supports two types of data types

  • Value type data types
  • Reference type data types

 

Value type Data typesReference type Data types
1) Whenever a data type is derived from structure then it is said to be value type data type.1) Whenever a data type is derived from a class definition then it is said to be value type data type.
2) The variable information and the value will be maintained at the stack memory.Ex: public I as integer = 10I [10] s to 3 stack memory2) The variable information will be maintained at the stack memory and value will be maintained at heap memory.Ex: public S as string = VB.NetS[H10T] 5105stack memory —-> [vbrowser] H107 heap memory
3) Inheritance is not supported3) Inheritance is supported.
4) Default values will be assignedEx: integer à 0Boolean à false4) Default value for any reference type member type member will be null value.
5) value type data types are bytes, s bytes, integer, u integer, short, u short, long, double, decimal, Boolean, char, date time, enum & structure etc.5) Reference type data types are string, object, interface, delegate and class.

 

 

Observation:

  • The default modifier is private
  • The default data type is an object.

 

DIM (Dimensions):

It is same as private modifier but the difference is the DIM modifier can be used anywhere within the application.

‘‘Demo on members
Imports system
Module Members ‘‘Demo
Class Test
Public is as integer instance member
Public shared as integer shared member
End class
Sub main ( )
Test.s = 100
Dim t1 As New Test
t1.i = 1000
Dim t2 As New Test
t2.i = 2000
Console.Writeline (“{0}, {1}, {2}”, Test.S, t1.i, t2.i)
End sub
End Module

 

Observation:

Screenshot_24

 

 

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Data Types and variables in vb.net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.
    Three + 6