Hey everyone, I am trying to (temporarily!) do some ASP.NET and C# compiling on my iMac.
Haha, it's so funny trying to do this on an iMac, it feels so.. wrong!
Anyway, I've found that Mono is the best way to do this, in my opinion.
I have a simple ASP.NET page with the following code:
1 <%@ Page Language="C#" %>
2 <html>
3 <head>
4 <title>Planting Trees</title>
5 <script runat="server">
6 protected void Page_Load(Object Source, EventArgs E)
7 {
8 string msg = "Let's plant some trees!<br/>";
9
10 // Create a new Tree
11 Tree tree1 = new Tree();
12
13 msg += "I've created a tree with a height of " +
14 tree1.height + " metre(s).<br/>";
15
16 tree1.Grow();
17
18 msg += "After a bit of growth, it's now up to " +
19 tree1.height + " metre(s) tall.<br/>";
20
21 Tree tree2 = new Tree();
22 Tree tree3 = new Tree();
23 tree2.Grow();
24 tree3.Grow();
25 tree2.Grow();
26 tree3.Grow();
27 tree2.Grow();
28 msg += "Here are the final heights:<br/>";
29 msg += " tree1: " + tree1.height + "m<br/>";
30 msg += " tree2: " + tree2.height + "m<br/>";
31 msg += " tree3: " + tree3.height + "m<br/>";
32
33 Output.Text = msg;
34 }
35 </script>
36 </head>
37 <body>
38 <p><asp:label runat="server" id="Output" /></p>
39 </body>
40 </html>
Now, I have this simple C# class to go along with it:
// Tree.cs, A simple C# class
public class Tree {
public int height = 0;
public void Grow() {
height += 1;
}
}
Now, the ASP.NET page is located in my home directory on my iMac and the .cs C# class file is located under bin
in the home directory.
Now, I'm not 100% sure, but do I need to compile the .cs
into a .dll
for this to work?
Any suggestions are greatly appreciated!