js to C# - GetComponent.().ScreenPointToRay

Hi! need help to js to C# convertion:

var ray = GetComponent.<Camera>().ScreenPointToRay (Input.mousePosition); 
//ray from camera to mouse position, we use this for clicking on balls

Try if this works:

using UnityEngine;
using System.Collections;

public class YOURCLASSNAME : MonoBehaviour
public Ray ray= GetComponent.().ScreenPointToRay (Input.mousePosition);


You could use this:

Ray ray = GetComponent< Camera>().ScreenPointToRay(Input.mousePosition);

But it would be easier and faster to use the property camera directly:

Ray ray = camera.ScreenPointToRay(Input.mousePosition);

Notice that in both cases the script must be attached to a camera, or you will get Null Reference errors.