0

Hi guys I encounter an error everytime I run my recursion program which contains a
messagebox.

Here is the error: The name 'MessageBox' does not exist in the current context

and here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication10
{
    class Program
    {
       
      static void Main(string[] args)
      {

       string [] fruits = {"apple", "mango", "banana"};

       foreach(string fruit in fruits)

           {
             MessageBox.Show("apple");
           }

        
        }
    }
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Momerath
0

MessageBox is a Winform object. Based on the 'ConsoleApplication10' I'd say you are writing a Console application, thus, no MessageBox.

If you want output, use Console.WriteLine.

Oh, and there is no recursion anywhere in that code.

Edited by Momerath: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.