Accessing VB.Net class in App_Code from C# code behind

Last Reply 2 months ago By pandeyism

Posted 2 months ago

SIr,

 In my App_Code I have made class file in .vb. Now need to access that file class in c# code behind. 

The class file is inaccessible in c# code behind file.

How should I do that.

You are viewing reply posted by: pandeyism 2 months ago.
Posted 2 months ago

Hi Sumeet,

Please refer below sample.

Vb class can  access in C# code behind, refer below sample.

Default.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    Customer cust = new Customer();
    Response.Write("Name is: " + cust.GetFirstName() + " " + cust.GetLastName());
}

Customer.VB

Public Function GetFirstName() As String
    Return "Mudassar"
End Function

Public Function GetLastName() As String
    Return "Khan"
End Function

Output

Name is: Mudassar Khan