Lecture overview -- Keyboard shortcut: 'u'  Previous page: Procedures and Functions -- Keyboard shortcut: 'p'  Next page: Object-oriented programming in Visual Basic -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Introduction to C# - slide 38 : 43

Combined C# and Visual Basic Programming
A client written in Visual Basic and a server written in C#
using System;

public class Die {
  private int numberOfEyes;
  private Random randomNumberSupplier; 
  private const int maxNumberOfEyes = 6;

  public Die(){
    randomNumberSupplier = new Random(unchecked((int)DateTime.Now.Ticks));
    numberOfEyes = NewTossHowManyEyes();
  public void Toss(){
    numberOfEyes = NewTossHowManyEyes();

  private int NewTossHowManyEyes (){
    return randomNumberSupplier.Next(1,maxNumberOfEyes + 1);

  public int NumberOfEyes() {
    return numberOfEyes;

  public override String ToString(){
    return String.Format("[{0}]", numberOfEyes);
Imports System

Module DieApplication

  Sub Main()
    Dim D1 as new Die()
    Dim D2 as new Die()

    For i as Integer = 1 To 10
    Next i
  End Sub 

End Module
Compilation and execution.