สามารถเรียกใช้ฟังก์ชันได้ แต่ไม่มีการส่งค่า ดังตัวอย่าง
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace VoidFunctionTest { class Program { static void Main(string[] args) { printTest("Hello Word", 10); Console.ReadLine(); } static void printTest(string x, int y) { for (int i = 0; i < y; i++) { Console.WriteLine(x); } } } }
ผลการรัน
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word
Hello Word