Converting Script from Java to C#

I usually don’t do this kind of stuff but could someone help me convert this? My biggest problem is to know what var type’s h and w are. If someone could help me, it would be much appreciated!

@script ExecuteInEditMode()
var crosshair : Texture2D;
public var widthcross : int;
public var heightcross : int;
function OnGUI () 
	{
	var w = crosshair.width/widthcross;
	var h = crosshair.height/heightcross;
	position = Rect((Screen.width - w)/2,(Screen.height - h )/2, w, h);
	GUI.DrawTexture(position, crosshair);
	}

Not tested, but something like the following should work:

using UnityEngine;

[ExecuteInEditMode]
public class YourScriptName : MonoBehaviour {
    public Texture2D crosshair;
    public int widthcross;
    public int heightcross;

    void OnGUI() {
        // Only draw textures for repaint events.
        if (Event.current.type == EventType.Repaint) {
            int w = crosshair.width / widthcross;
            int h = crosshair.height / heightcross;
            Rect position = new Rect((Screen.width - w) / 2, (Screen.height - h) / 2, w, h);

            GUI.DrawTexture(position, crosshair);
        }
    }
}

Define a class, and import System.Collections and UnityEngine. Instead of using something like var widthcross : int, in C# this would be public int widthcross. Public makes properties available for changing in the inspector, as well as accessible from other scripts. Be sure to name your C# script the same as your class.

Example.cs

using UnityEngine;
using System.Collections;

[ExecuteInEditMode]

public class Example : MonoBehaviour 
{
	public Texture2D crosshair;
	public int widthcross;
	public int heightcross;
	float w;
	float h;
	Rect position;
	
	void OnGUI () 
	{
	    w = crosshair.width/widthcross;
	    h = crosshair.height/heightcross;
	    position = new Rect((Screen.width - w)/2,(Screen.height - h )/2, w, h);
	    GUI.DrawTexture(position, crosshair);
    }
}