0
点赞
收藏
分享

微信扫一扫

Windows远程桌面连接

Jonescy 2024-06-15 阅读 24
c#

C#参数使用场景简要说明

1、传值参数

2、输出参数

3、引用参数

4、具名参数

5、方法扩展(this参数)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
//this参数(扩展方法)
namespace PamametersExample9
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> vs = new List<int>() { 11, 21, 13, 1, 15 };
            bool b = AllCreateThanTen(vs);
            //lambda表达式
            bool b1 = vs.All(i => i > 10);
            Console.WriteLine(b);
            Console.WriteLine(b1);
        }
        static bool AllCreateThanTen( List<int> vs)
        {
            foreach (var item in vs)
            {
                if (item <= 10)
                {
                    return false;
                }
            }
            return true;
        }
    }
}

6、可选参数

7、数组参数

举报

相关推荐

0 条评论