Chapter 3: Learning Just Enough C# and VB.NET: Types and Members

79

namespace FirstProgram

{

class Program

{

static void Main(string[] args)

{

Calc mathProg = new Calc();

int squaredInt = mathProg.SquareInt(3); Console.WriteLine("3 squared is " + squaredInt);

Console.ReadKey();

}

}

}

C# (Calc.cs):

using System;

using System.Collections.Generic; using System.Linq;

using System.Text;

namespace FirstProgram

{

public class Calc

{

public int SquareInt(int number)

{

return number * number;

}

}

}

VB (Module1.vb):

Module Module1

Sub Main()

Dim mathProg As New Calc()

Dim squaredInt As Integer = mathProg.SquareInt(3)

Console.WriteLine("3 squared is " & squaredInt)

End Sub

End Module

Page 102
Image 102
Microsoft 9GD00001 manual # Calc.cs