Como usar [DllImport (“”)] em c #?

Eu encontrei muitas perguntas sobre isso, mas ninguém explica como eu posso usar isso.

Eu tenho isto:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.FSharp.Linq.RuntimeHelpers;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.IO;

public class WindowHandling
{
    public void ActivateTargetApplication(string processName, List<string> barcodesList)
    {
        [DllImport("User32.dll")]
        public static extern int SetForegroundWindow(IntPtr point);
        Process p = Process.Start("notepad++.exe");
        p.WaitForInputIdle();
        IntPtr h = p.MainWindowHandle;
        SetForegroundWindow(h);
        SendKeys.SendWait("k");
        IntPtr processFoundWindow = p.MainWindowHandle;
    }
}

Alguém pode me ajudar a entender por que isso me dá um erroDllImport linha e nopublic static linha?

Alguém tem uma ideia, o que posso fazer? Obrigado.

questionAnswers(1)

yourAnswerToTheQuestion