+ 1

Please let me know why this error is coming here

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static string myMessage() { return "Hi"; } static void Main(string[] args) { string message = myMessage; Console.WriteLine(message); } } }

13th May 2019, 10:35 AM
Shaik Shabbeer
Shaik Shabbeer - avatar
3 Réponses
+ 2
It should be: string message = myMessage(); You have written myMessage as a function, and functions should be followed by brackets.
13th May 2019, 10:42 AM
Rincewind
Rincewind - avatar
+ 1
myMessage() need parenthesis to execute the function ~
13th May 2019, 10:41 AM
Gordon
Gordon - avatar
0
Thank you so much
13th May 2019, 10:52 AM
Shaik Shabbeer
Shaik Shabbeer - avatar