From 99184b731280aef4e8068b1dfd831875e413e0db Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Wed, 13 Nov 2024 11:27:45 +0100 Subject: [PATCH] added new class --- Emne 3/ConsoleApp1/ConsoleApp1/MyConsole.cs | 12 ++++++++++++ Emne 3/ConsoleApp1/ConsoleApp1/Program.cs | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Emne 3/ConsoleApp1/ConsoleApp1/MyConsole.cs diff --git a/Emne 3/ConsoleApp1/ConsoleApp1/MyConsole.cs b/Emne 3/ConsoleApp1/ConsoleApp1/MyConsole.cs new file mode 100644 index 0000000..cd7de1f --- /dev/null +++ b/Emne 3/ConsoleApp1/ConsoleApp1/MyConsole.cs @@ -0,0 +1,12 @@ +namespace ConsoleApp1; + +public class MyConsole +{ + + public static string Ask(string question) + { + Console.Write(question); + return Console.ReadLine(); + } + +} \ No newline at end of file diff --git a/Emne 3/ConsoleApp1/ConsoleApp1/Program.cs b/Emne 3/ConsoleApp1/ConsoleApp1/Program.cs index 36022e5..de396c0 100644 --- a/Emne 3/ConsoleApp1/ConsoleApp1/Program.cs +++ b/Emne 3/ConsoleApp1/ConsoleApp1/Program.cs @@ -4,10 +4,13 @@ internal class Program { static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + + var name = MyConsole.Ask("What is your name?"); + Console.WriteLine($"Hello {name}!"); var number = GetNumber(); } + static int GetNumber() { return 7;