1. using System;
  2. class Program
  3. {
  4. static void Main()
  5. {
  6. Console.WriteLine("Welcome to the Greeting Program!");
  7. Console.Write("Please enter your name: ");
  8. // Read user input
  9. string userName = Console.ReadLine();
  10. // Greet the user
  11. Console.WriteLine($"Hello, {userName}! Welcome to C# programming.");
  12. // Keep the console window open until a key is pressed
  13. Console.WriteLine("\nPress any key to exit...");
  14. Console.ReadKey();
  15. }
  16. }
 
 

109

Pasted Text #34501

作者 Rosa Dunn

The C# code provided is a simple console application that prompts the user for their name, greets them with a personalized message, and waits for any key press before exiting.

PasteBin

行數
20
字數
56
大小
526 位元組
建立時間
類型
text/x-csharp
All Rights Reserved ((C))
登入以留下評註!