PolinaKoleva

HelloMethod

Jan 21st, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using System;
  2. //Write a method that asks the user for his name
  3. //and prints “Hello, <name>” (for example, “Hello, Peter!”).
  4. //Write a program to test this method.
  5.  
  6. class Problem1MethodHello
  7. {
  8.     static void Greetings()
  9.     {
  10.         Console.WriteLine("What`s your name?");
  11.         string name = Console.ReadLine();
  12.         Console.WriteLine("Hello, {0}!", name);
  13.     }
  14.     static void Main()
  15.     {
  16.         Greetings();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment