0

C# course "Welcome!" class example quiz

Hey guys, I just started the C# course and tried to solve the problem of the "Welcome" class example quiz. Unfortunately I don't know why it won't work correctly.... Here is the code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { class Welcome { public WelcomeMessage() { Console.WriteLine("Welcome to OOP"); } } static void Main(string[] args) { //create a Welcome object with the same name Welcome c = new Welcome(); c.WelcomeMessage(); } } } It should print "Welcome to OOP" but I only get the message that there is no input and no output. What do I do wrong? Thanks in advance Best regards Flo :)

4th Dec 2020, 9:54 AM
Flo
Flo - avatar
4 Antworten
+ 7
Flo , WelcomeMessage () method should be void => public void WelcomeMessage ()
4th Dec 2020, 9:58 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Ah ok, I thought it will set the return to void by default. Thanks a lot :)
4th Dec 2020, 10:44 AM
Flo
Flo - avatar
0
uuouoyupyu
24th Jun 2023, 3:55 AM
BALAMURUGAN B
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { //create a Welcome object with the same name Welcome welcome = new Welcome(); welcome.WelcomeMessage(); } } class Welcome { //complete the class, add WelcomeMessage() method public void WelcomeMessage(){ Console.WriteLine("Welcome to OOP"); } } }
27th Jan 2024, 5:53 AM
S8ul Yuvraj
S8ul Yuvraj - avatar