VB.NET - Difference and similarity between a class and a structure

Difference and similarity between a class and a structure in VB.NET.

ClassesStructures
It is used for large amounts of data.It is used for smaller amounts of data.
It can be inherited.It cannot be inherited.
It can be NULL.It cannot be NULL like the class.
It can have destructor.It cannot have destructor.
It can be abstract.It cannot be abstract.
The keyword for class is 'class'.The keyword for structure is 'struct'.
Class member variables are private by default.Structure members have public access by default.
It contains a volatile field.It cannot contain volatile field.
Fields are automatically initialized.Fields are not automatically initialized.
You cannot use sizeof operator.You can use sizeof operator.
Syntax:
class <Class_name>
{
static void main(string[ ] args)
{
//Statements
}
}
Syntax:
struct <Structure_name>
{
//variable_declaration
};
Example:
class A
{
static void main(string[ ] args)
{
//Statements
}
}
Example:
struct Student
{
int rollno;
char stud_name;
char address;
};
VB.NET - What is implicit cast and explicit cast in .Net?
Implicit cast and explicit cast in .Net - Implicit cast allows conversion without any loss of data and it takes place only when there is no possible of loss of data. ....
VB.NET - Imperative and declarative security
Imperative and declarative security - Imperative security is implemented by calling methods of Permission objects in code at run time........
VB.NET - Anchoring and Docking in .NET.
Anchoring and Docking - Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form........
Post your comment