Structure in Visual Basic .NET

Structure in Visual Basic .NET is user defined data type. You can have different types of data used in Structures

Structure in Visual Basic is similar to Class. But they have different features too. I will discuss them in following section

This is how you define the Student structure

 

Create a new Student

You can use Dim to create new student and you can assign to values too .This is same like what you work with other data type

Add properties to structure

 

Similarities

Structures and classes are similar in the following respects:

  • Both can have other data types as members
  • Both have members, which can include constructors, methods, properties, fields, constants, enumerations, events, and event handlers
  • Members can have access level Private and Public

Differences

  • Structures and classes differ in the following particulars:
  • Structures are value types; classes are reference types.
  • Structures are value types; classes are reference types.
  • Structures are not inheritable; classes are
  • A structure does not require a constructor; a class does

Leave a Reply

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