How do I make onMouseDown work for OnGUI in C#?

Currently I have the js version:

var _mouseDown = false;
function OnGUI() {
if(_mouseDown) {

 GUI.Box(Rect(10,10,100,20),"object!");

}
}
function OnMouseDown () {
_mouseDown = true;
}
function OnMouseUp () {
_mouseDown = false;
}

function OnMouseOut() {

_mouseDown = false; 
}

However, I can’t seem to get the same thing for C#. When I try to rewrite it with void onMouseDown, I get errors. Here is a sample from the reference manual that I want to use but I can’t seem to add onMouseDown properly to get it to work.

using UnityEngine;
using System.Collections;

public class TextLabelC : MonoBehaviour {
	
void OnGUI() {
    GUI.Box(new Rect(10, 10, 100, 20), "Object");

}

}

Also, for my above script in js, I am wondering how do I make the label stay on the screen without having to hold and press the mouse down but also, having it disappear when navigating to another object

Hi, If i remember correctly you can use Event handler.

if (Event.current.type == EventType.MouseDown){

}

You can even pre save it if you need to use it many times.

Event e = Event.current;
if (e.type == EventType.MouseDown){

}