[我的ASP.net学习历程]out

类别:Asp 点击:0 评论:0 推荐:

<%@ Page Language="C#" %>
<script runat="server">

    void Page_Load()
    {
        int a = 1;
        int b;
        Increment(a, out b); //out和ref的区别就是out可以不先初始化
        lblMessage.Text = b.ToString();
    }
   
    void Increment(int Number, out int Result)
    {
        Result = Number + 1;
    }

</script>
<html>
<head>
    <title>Chapter 5 - Demonstration of using out Parameters</title>
</head>
<body>
    <asp:Label id="lblMessage" runat="server"></asp:Label>
</body>
</html>

本文地址:http://com.8s8s.com/it/it8558.htm