亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JS參數傳遞只能是按值嗎?

JS參數傳遞只能是按值嗎?

qq_花開花謝_0 2018-07-17 08:05:33
下面是我看到的js參數傳遞的方法,其中說js只有按值傳遞 以上是我在《javascript高級程序設計》中看到的。然后我用C#寫了下面這段代碼using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace refTest{       class Program    {        static void SomeFunction(int[] ints, int i)        {            ints[0] = 100;            ints = new int[] { 3, 4, 5, 9, 8 };            i = 100;        }                static void Main(string[] args)        {            int i = 0;            int[] ints = { 0, 1, 2, 4, 8 };            Console.WriteLine("i = " + i);            Console.WriteLine("ints[0] = " + ints[0]);            Console.WriteLine("Call SomeFunction.");            SomeFunction(ints, i);            Console.WriteLine("i = " + i);            Console.WriteLine("ints[0] = " + ints[0]);        }    }} 結果發現和JS中的情形是一樣的,難道C#的引用類型不是按引用傳遞的嗎?
查看完整描述

2 回答

?
偶然的你

TA貢獻1841條經驗 獲得超3個贊

最討厭糾結中文的表達的一些概念了,多少人繞不出來啊。

你可以嘗試在c#中寫第二個示例,結果是不成立的,是有區別的。


查看完整回答
反對 回復 2018-07-30
  • 2 回答
  • 0 關注
  • 548 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號