I have this simple ASP.NET page here:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Tree.aspx.cs" Inherits="CoconutTree.One" %>
<html>
<head>
<title>Planting Trees</title>
<script runat="server">
protected void Page_Load(Object Source, EventArgs E)
{
string msg = "Let's plant some trees!<br/>";
// Create a new Tree
Tree tree1 = new Tree();
msg += "I've created a tree with a height of " +
tree1.height + " metre(s).<br/>";
tree1.Grow(3);
msg += "After a bit of growth, it's now up to " +
tree1.height + " metre(s) tall.<br/>";
msg += "Maybe eventually it will grow to 10 meters tall!</br>…<br/>";
tree1.Grow(7);
msg += "*15 years later*<br/>Let's check out our tree's height now! It's now up to " + tree1.height + " meter(s) tall! Awesome!<br/>";
Output.Text = msg;
string msg2 = "Let's plant some coconut trees!<br/>";
// Create a new Tree
CoconutTree coconutTree1 = new CoconutTree();
msg2 += "I've created a tree with " + coconutTree1.numNuts + " coconuts.<br/>";
coconutTree1.GrowNut(10);
ms2 += "I've now grown " + coconutTree1.numNuts + " coconuts on our tree.<br/>";
Output2.Text = msg2;
}
</script>
</script>
</head>
<body>
<p><asp:label runat="server" id="Output" /></p>
<p><asp:label runat="server" id="Output2" /></p>
</body>
</html>
With this simple class:
namespace One
{
public class Tree {
public int height = 0;
public void Grow(int heightToGrow) {
height += heightToGrow;
}
}
public class CoconutTree : Tree {
public int numNuts = 0; //Number of coconuts
public void GrowNut(int numberToGrow) {
numNuts += numberToGrow;
}
public void PickNut(int numberToPick) {
numNuts -= numberToPick;
}
}
}
UPDATE UPDATE:
Parser Error
Description: Error parsing a resource required to service this request. Review your source file and modify it to fix this error.
Parser Error Message: Cannot find type CoconutTree.One