Interoperating with Different Programming Languages

The objective of this section is to illustrate that .NET really supports cross-programming language use. You will learn how classes defined in one programming language can be subclassed in another and utilized in yet another. First, define the Base class in C#.

using System;
namespace mixed
{
  public class Base
  {
    public Base()
    {
    }
    public virtual String GetLanguage()
    {
        return "C#";
    }
  }
}

This program is compiled into a library using the C# compiler.

csc /t:library CSharp.cs

Next, a Visual Basic .NET class is declared as a subclass of the Base class.

 Imports System Namespace mixed Public class Derived Inherits Base Public Sub New() End Sub Public Overrides Function GetLanguage() As String ...

Get Microsoft® .NET Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.