Nov
04

using System;
class N1
{  
    //输出参数示例
    /*
    void sum(int a, int b,out int result)
    {
        result= a + b;
    }
    static void Main()
    {
        N1 n = new N1();
        int a = 15, b = 30,r;
        n.sum(a, b,out r);
        Console.WriteLine("两种之和为:{0}",r);
    }
    */
    //值参数示例。值不被修改
    static void plus(int p)
    {
        p++;
        Console .WriteLine ("p++的值={0}",p);
    }
    static void Main()
    {
        int p = 15;
        Console.WriteLine("传入的p值:{0}", p);
        plus(p);
        Console.WriteLine("返回的p值:{0}",p);
    }
   
    /*引用参数
    static void plus(ref int p)
    {
        p++;
        Console.WriteLine("p++的值={0}", p);
    }
    static void Main()
    {
        int p = 15;
        Console.WriteLine("传入的p值:{0}", p);
        plus(ref p);
        Console.WriteLine("返回的p值:{0}", p);
    }
     */

标签:


随机文章:

最近阅读过此文章的网友:

Tags:

没人甩我?!

到此一游

注意: 你可以使用如下标签代码: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

| || |
由yo2提供博客服务 |Theme created by In My Pad.