Converting JavaScript to C#

//On All The Possible Targets
var myPlayer:Transform;
//Set this in Start() with GameObject.FindObjectWithTag(“Player”);

function OnMouseUpAsButton()
{
//myPlayer is the one targeting Get the script responsible for target attacks
//target would be the one you lock onto

myPlayer.GetComponent(PlayersTargetAttackScript).target=transform;

}
Then just add the var target on your players “PlayersTargetAttackScript” and say

if(target!=null)AttackTarget(); //or whatever

How would i program this in C#

There are lots of resources out there explaining how to convert between JS and C#. Start with this page:

http://fragileearthstudios.com/2011/10/18/unity-converting-between-c-and-javascript-2/

And try google searches along the lines of 'unity convert between JS and C#." Also check around on this site - this is a question that has been asked and answered numerous times.

What you have here isnt much different in C#. Just change:

function OnMouseUpAsButton() to void OnMouseUpAsButton().

And referencing a component in C# is:

myPlayer.GetComponenet<PlayersTargetAttackScript>();

The rest would be the same as in JS.