get script of another gameobject in c#

i have a script attached to my main camera (named mainScript, in c#) which i want to access with another script (c#).

it should be as easy as
but this throws out the following errors:

error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
error CS1502: The best overloaded method match for `UnityEngine.GameObject.GetComponent(System.Type)' has some invalid arguments
error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'

on the other hand,Camera.main.GetComponent ("Main Script") works but then adding .function or .variable throws out

error CS1061: Type `UnityEngine.Component' does not contain a definition for `midFlight' and no extension method `midFlight' of type `UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)

im really confused atm as i dont get what im doing wrong and i already used these without problem in js code

It is easiest to use the generic version of GetComponent in C#:


You could also do: