How to declare C# variable

I’m having trouble converting the following from Javascript to C# as I do not know what to declare the following variable as:

function Update()
{
	var hit : RaycastHit;
	var fwd = transform.TransformDirection(Vector3.forward);
	
	if(Physics.Raycast(transform.position, fwd, hit, rayLength))

Have tried:

void  Update (){
		RaycastHit hit;
		fwd = transform.TransformDirection(Vector3.forward);
		
		if(Physics.Raycast(transform.position, fwd, hit, rayLength))

But it doesn’t work. How do I declare variables of this type in C#?

void Update (){
RaycastHit hit;
Vector3 fwd = transform.TransformDirection(Vector3.forward);

         if(Physics.Raycast(transform.position, fwd, out hit, rayLength))

You were just missing Vector3 at the start of fwd so C# didn’t know what it was you were trying to make. Also in C# you need to add ‘out’ before variables that will gather info from a function as far as I understand it so that is why that is before hit in the raycast.

There is actually a var keyword in C# also which uses compile time type inference.
You could rewrite the code to something like this in C#:

void Update()
{
    RaycastHit hit;
    var fwd = transform.TransformDirection(Vector3.forward);
     
    if(Physics.Raycast(transform.position, fwd,out hit, rayLength))
	{
		// todo
	}
 
	///.. rest of your update function
 }

The answer was a combination of both answers provided by VSZM and Turkeybag! Cheers guys!

	void  Update (){
		RaycastHit hit;
		var fwd = transform.TransformDirection(Vector3.forward);
		
		if(Physics.Raycast(transform.position, fwd, out hit, rayLength))