• 参数传递


    代码
    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);
            }
        }
    }
  • 相关阅读:
    LeetCode#1047-Remove All Adjacent Duplicates In String-删除字符串中的所有相邻重复项
    LeetCode#345-Reverse Vowels of a String-反转字符串中的元音字母
    LeetCode#344-Reverse String-反转字符串
    LeetCode#232-Implement Queue using Stacks-用栈实现队列
    LeetCode#225-Implement Stack using Queues-用队列实现栈
    LeetCode#20-Valid Parentheses-有效的括号
    树的遍历
    [leetcode] 树(Ⅰ)
    二叉树图形化显示
    你错在成长于文明的边陲
  • 原文地址:https://www.cnblogs.com/sagacite/p/1869553.html
Copyright © 2020-2023  润新知