vs2015 dynamicweb3-1 计算圆的面积

webform1.aspx 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicweb3_1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblOutput" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

webform1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace dynamicweb3_1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        //计算圆的面积:

        const double PI = 3.1415926d;
        double radius = 8.5;
        double area = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            area = radius * radius * PI;
            lblOutput.Text = "圆的面积是:" + area.ToString();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/modern358/article/details/115036407