当前位置: 代码迷 >> 综合 >> 函数的参数不一定是要程序传值进去的,它也有可能不用传值,而是作为返回值,比如out
  详细解决方案

函数的参数不一定是要程序传值进去的,它也有可能不用传值,而是作为返回值,比如out

热度:87   发布时间:2024-01-17 03:36:23.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{class Class1{/*** 函数的参数不一定是要程序传值进去的,它也有可能不用传值,而是作为返回值,比如out*/static void Main(string[] args){int i;bool b = int.TryParse("112", out i);// public static bool TryParse(string s, out int result);// TryParse的第二个参数不用程序传值进去,它是当做返回结果用的Console.WriteLine(i);// 112Console.WriteLine(b);// true// out的应用场景是:当函数需要多个返回值的时候可以用out,return只能是一个返回值Console.ReadKey();}}
}


  相关解决方案