Java |
// HelloLibrary.java
package Microsoft.CSharp.Introduction;
public class HelloLibrary
{
public String getMessage() {
return "hello, world";
}
}
>javac -d HelloLibrary.java
The above command produces a HelloLibrary.class
file stored at Microsoft\CSharp\Introduction\
subdirectory
// HelloApp.java
import Microsoft.CSharp.Introduction;
class HelloApp
{
public static void main(String[] args) {
HelloLibrary m = new HelloLibrary();
System.out.println(m.getMessage());
}
}
>javac HelloApp.java
>java HelloApp
hello, world
|
|
C# |
// HelloLibrary.cs
namespace Microsoft.CSharp.Introduction
{
public class HelloMessage
{
public string Message {
get {
return "hello, world";
}
}
}
}
>csc /target:library HelloLibrary.cs
The above command produces a class library HelloLibrary.dll
// HelloApp.cs
using Microsoft.CSharp.Introduction;
class HelloApp
{
static void Main() {
HelloMessage m = new HelloMessage();
System.Console.WriteLine(m.Message);
}
}
>csc /reference:HelloLibrary.dll HelloApp.cs
//The above command produces an application HelloApp.exe file
When executed, printout:
hello, world
|
|