Monday, April 30, 2012

Inheritence

VB.NET

Class Employee
Public EmpId As Integer
Private Sal As Double = 0
Public Basic As Double
Public Allowance As Double
Public Deducions As Double
Public FirstName As String
Public LastName As String
Public Address As String
Public Pincode As String
Public Sub DisplayInfo()
Dim msg As String
msg = FirstName & " " & LastName & vbCrLf
msg = msg & Address & vbCrLf
msg = msg & "PIN – " & Pincode
Msgbox(msg)
End Sub
Public ReadOnly Property Salary() As Double
Get
Return Sal
End Get
End Property
Public Sub ProcessSalary()
Sal = Basic + Allowance - Deductions
End Sub
End Class


C#

class Employee
{
public int EmpId;
private double Sal = 0;
public double Basic;
public double Allowance;
public double Deducions;
public string FirstName;
public string LastName;
public string Address;
public string Pincode;
public void DisplayInfo()
{
string msg;
msg = FirstName + " " + LastName + vbCrLf;
msg = msg + Address + vbCrLf;
msg = msg + "PIN – " + Pincode;
MesssgeBox.Show(msg);
}
public double Salary
{
get
{
return Sal;
}
}
public void ProcessSalary()
{
Sal = Basic + Allowance – Deductions;
}
}

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...