Optional parameters
static void test1() { func1("A"); func1("B", 30); Console.ReadKey(); } static void func1(string name, int age = 20) { Console.WriteLine("Name: " + name + "\t Age: " + age); }
Named parameters
static void test2() { func2("C", 40); func2(age: 50, name: "D"); Console.ReadKey(); } static void func2(string name, int age) { Console.WriteLine("Name: " + name + "\t Age: " + age); }
Optional parameters combined with named parameters
static void test3() { func3("E"); func3("F", 10, false); func3("G", 15); func3("H", isMale: false); Console.ReadKey(); } static void func3(string name, int age = 20, bool isMale = true) { Console.WriteLine("Name: " + name + "\t Age: " + age + "\t IsMale: " + isMale); }
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Roblox: Dead Rails - How To Complete Every Challenge
4 weeks agoByDDD
Atomfall guide: item locations, quest guides, and tips
4 weeks agoByDDD

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version