<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <%
        //myeclipse格式化代码快捷键:ctrl+shift+f
        //vs2012格式化代码快捷键:ctrl+k+d
        //计算最大的值
        int[] values = { 25, 70, 85, 50 };
        int max = 0;
        foreach (int value in values)
        {
            if (value > max)
            {
                max = value;
            }
        }       
    %>
    <!-- 输出最大值 -->
    <h3>最大值是<%=max %></h3>
    <br />
    ================================================
    <br />
    <script runat="server">
        String message = "显示最大值:";
        int GetMax(int[] values)
        {
            int max = 0;
            foreach (int value in values)
            {
                if (value > max)
                {
                    max = value;
                }
            }
            return max;
        }
    </script>
    <h3><%=message+GetMax(new int[]{ 25, 70, 85, 50 }) %>
    或者:<%:message+GetMax(new int[]{ 25, 70, 85, 50 }) %></h3>
    <!--上面两种表达式是相同的-->

</body>
</html>