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");
           }

        
        }
    }
}

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.