日期:2014-05-18 浏览次数:20885 次
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>我看书上说这里写的继承不一样??? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>第一个测试页面</title> </head> <script runat="server"> protected void Page_Load(object src, EventArgs e) { Response.Write("<h2>Load event fired!<h2>"); } </script> <body> <h2> 32 degrees fahrenheit is <%= TempConverter.FahrenheitToCentigrade(32) %>运行的时候这里出现错误,提示没有这个:CS0103: 名稱 'TempConverter' 不存在於目前內容中 </h2> <form id="form1" runat="server"> <div> </div> </form> </body> </html>
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; //[assembly : AssemblyKeyFile("pubpriv.snk")] //[assembly : AssemblyVersion("1.0.0.0")] namespace WebApplication1 { public class TempConverter { static public double FahrenheitToCentigrade(double val) { return ((val - 32) / 9) * 5; } static public double CentigradToFahrenheit(double val) { return (val * 9) / 5 + 32; } } }