Strange, Giving me 6 errors in editor but in the script/s in visual studio no errors at all ?

When I’m trying to build my game I’m doing Build And Run I’m getting in the editor some errors/exceptions :

But then I make double click on the first error and it’s sending me to the script :

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

[Serializable]
public class AutocompleteSearch
{
    static class Styles

But there is no error/s here. IMGUI is found and fine.
I can build in the visual studio I can run the game. And yet it give some errors but they are not exist in the visual studio only in the editor.

I tried to close and re open the visual studio and also to close and re open the unity editor. Same problem.

You can see in this screenshot that I can build the scripts in the visual studio without any errors or exceptions :

But in the editor when building it gives the errors. I can’t figure out what is going on why in the editor there are errors but in the visual studio none.

And I can run the game in the editor without a problem but can’t build.

the UnityEditor namespace is not available in a build and can only be used in the editor.

Use the unity editor preprocessor directive

#if UNITY_EDITOR
using UnityEditor;
#endif

Also, make sure you aren’t using any editor code at runtime or any editor code isn’t required when playing your game in a build.