Check out example codes for "error CS0542". It will help you in understanding the concepts better.

Code Example 1

// make sure that your function doesn't have the same name as the script

//example:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Respawn : MonoBehaviour{
  
  public void Respawn()
    {
        SceneManager.LoadScene(1);
    }
}

//answer:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Respawn : MonoBehaviour{
  
  public void Respawning()
    {
        SceneManager.LoadScene(1);
    }
}

Learn ReactJs, React Native from akashmittal.com