zoukankan      html  css  js  c++  java
  • 参数传递

    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        
    class Program
        {
            
    static void Main(string[] args)
            {
                
    int b = 1;
                test(b);
                Console.WriteLine(b);
                my m 
    = new my();
                test2(m);
                Console.WriteLine(m.Value);

                test3(m);
                Console.WriteLine(m.Value);

                test4(
    ref m);
                Console.WriteLine(m.Value);

                Console.ReadLine();
            }
            
    private static void test(int a)
            {
                a 
    = 2;
            }
            
    private static void test2(my a)
            {
                a.Value 
    = 200;
            }

            
    private static void test3(my a)
            {
                a 
    = new my();
                a.Value 
    = 300;
            }
            
    private static void test4(ref my a)
            {
                a 
    = new my();
                a.Value 
    = 400;
            }
        }
        
    class my
        {
            
    public int Value = 100;
        }
    }
    代码
    package
    {
        
    import flash.display.Sprite;
        
        
    public class Test extends Sprite
        {
            
    private var refValue:Array;
            
    private var value:int;
            
    public function Test()
            {
                testArg(value,refValue);
                trace(value,refValue);
                refValue 
    = [0];
                value 
    = 0;
                testArg(value,refValue);
                trace(value,refValue);
                testArg2(value,refValue);
                trace(value,refValue);
            }
            
    private function testArg(value:int,refValue:Array):void{
                
                trace(
    this.value==value,this.refValue==refValue);
                value 
    = 1;
                refValue 
    = [1];
                trace(
    this.value==value,this.refValue==refValue);
            }
            
    private function testArg2(value:int,refValue:Array):void{
                
                trace(
    this.value==value,this.refValue==refValue);
                value 
    += 1;
                refValue.push(
    1);
                trace(
    this.value==value,this.refValue==refValue);
            }
        }
    }
  • 相关阅读:
    反转链表 16
    CodeForces 701A Cards
    hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)
    hdu 1241 Oil Deposits(水一发,自我的DFS)
    CodeForces 703B(容斥定理)
    poj 1067 取石子游戏(威佐夫博奕(Wythoff Game))
    ACM 马拦过河卒(动态规划)
    hdu 1005 Number Sequence
    51nod 1170 1770 数数字(数学技巧)
    hdu 2160 母猪的故事(睡前随机水一发)(斐波那契数列)
  • 原文地址:https://www.cnblogs.com/sagacite/p/1869553.html
Copyright © 2011-2022 走看看