Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The return keyword used in an example, within it's own class with two different methods.
- using System;
- namespace Return
- {
- public class ReturnString
- {
- public string ReturnFullName(string textOne, string textTwo)
- {
- return textOne + " " + textTwo;
- }
- public int ReturnMultiply(int one, int two)
- {
- return one * two;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Start();
- }
- private static void Start()
- {
- ReturnString returnname = new ReturnString();
- Console.WriteLine("First name: (x to exit)");
- string textOne = Console.ReadLine();
- if (textOne == "x")
- {
- Environment.Exit(0);
- }
- Console.WriteLine("Last name:");
- string textTwo = Console.ReadLine();
- Console.WriteLine("Enter a number:");
- int one = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter another number:");
- int two = int.Parse(Console.ReadLine());
- Console.WriteLine("Your full name is: " + returnname.ReturnFullName(textOne, textTwo));
- Console.WriteLine(one.ToString("#,##0") + " times " + two.ToString("#,##0") + " = " + returnname.ReturnMultiply(one, two).ToString("#,##0") + "\n\n");
- Console.WriteLine("Press a key...");
- Console.ReadKey();
- Console.Clear();
- Start();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement