help converting java s to c# s

im stuck converting this script from java to c#
ive done all that i can see but thecompiler is telling me
line 10 error CS1002: Expecting `;’ from what i can see it is how it should be and how ive seen in on other bits of script. it just dosnt like the raycasthit variable for some reason,
ps im new to scripting if the reason is obvious

java script

var object1: Transform;
var object2: Transform;
var hit : RaycastHit;

function Update () {
 if(Physics.Linecast(object1.position, object2.position, hit))
			{
				 if(hit.collider.gameObject.tag != object2.tag)
					{
					 Debug.Log("sight blocked by "+hit.collider.gameObject.name);
					 
					 Debug.DrawLine(object1.position, object2.position,Color.red);
					}
				else 
					{
					Debug.Log("sight not blocked");	
					Debug.DrawLine(object1.position, object2.position,Color.green);
					}
			}
}

C# script

using UnityEngine;
using System.Collections;

public class MYCLASSNAME : MonoBehaviour {
Transform object1;
Transform object2;


void  Update (){
line10 private RaycastHit hit;
 if(Physics.Linecast(object1.position, object2.position, hit))
			{
				 if(hit.collider.gameObject.tag != object2.tag)
					{
					 Debug.Log("sight blocked by "+hit.collider.gameObject.name);
					 
					 Debug.DrawLine(object1.position, object2.position,Color.red);
					}
				else 
					{
					Debug.Log("sight not blocked");	
					Debug.DrawLine(object1.position, object2.position,Color.green);
					}
			}
}
}

You can´t use “private” keyword inside a function. Just write RaycastHit hit;


RaycastHit hit;
if(Physics.Linecast(object1.position, object2.position, out hit))
{

I’ve not looked through the other pieces but this should fix this section.

All variables declared within functions are in function scope and so there is no need or use to declare whether a function variable is public protected or private. Basically Hit only exists within Update, and so no other function or class can access it anyway as it will be destroyed as soon as update is completed.

Also hit is an out parameter in that function and must be declared as such explicitly.