76Microsoft Visual Studio 2010: A Beginner’s Guide

{

MessagePrinter msgPrint = new MessagePrinter();

string[] customerNames = { "Jones", "Smith", "Mayo" }; string reportTitle = "Important Customer Report";

msgPrint.PrintCustomerReport(customerNames, reportTitle);

}

}

C# (MessagePrinter.cs):

using System;

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

using System.Text;

namespace FirstProgram

{

public void PrintCustomerReport(

string[] customers, string title = "Customer Report")

{

Console.WriteLine(title);

Console.WriteLine();

foreach (var name in customers)

{

Console.WriteLine(name);

}

}

}

}

VB (Module1.vb):

Module Module1

Sub Main()

Dim msgPrint As New MessagePrinter()

Dim customerNames = {"Jones", "Smith", "Mayo"}

Dim reportTitle As String = "Important Customer Report"

msgPrint.PrintCustomerReport(customerNames, reportTitle) End Sub

End Module

Page 99
Image 99
Microsoft 9GD00001 manual # MessagePrinter.cs