dcolumbus
dcolumbus

Reputation: 9722

C# 4 vs ActionScript 3: syntax differences

Look, before I get comments about how stupid I am for asking a question like this, I'd like it to be extremely clear that I understand that these two languages are vastly different. However, the way the languages are written happen to be quite similar.

I'm a heavy ActionScripter who has entered a .NET environment. What are the written syntax differences between the two? I'd like to use useful to the .NET team beyond my plug-in island.

example:

// AS   
private function SendMail():void {
    //do something
}

//C#
static void SendMail() {
    //do something
}

Upvotes: 2

Views: 3615

Answers (2)

Mark Knol
Mark Knol

Reputation: 10143

This is also a difference: In Actionscript 3, getters/setters are functions, in C# you define them inside the variable.

C#

    private string _Description;

    public string Description
    {
        get { return _Description; }
        set { _Description = value; }
    }

AS3

private var _description:String;

public function get description():String 
{ 
    return _description; 
}

public function set description(value:String):void 
{
    _description = value;
}

Upvotes: 3

mjfgates
mjfgates

Reputation: 3431

You've already seen the largest difference yourself: declarations in ActionScript are

[protection specifier] (function | var) name : type;

and in C# are

[protection specifier] type name; 

"static" is nearly the same between Actionscript and C#; the equivalent to your AS function header would be

private void SendMail() {} 

in C#.

The other most-visible difference, for me at least, is Object() and Array(), which are actual, you know, TYPES in C#, but are more sort of squishy throw-in-whatever-you-want things in AS. Or so it feels like to me-- I've just spent the last few weeks doing the exact opposite thing from what you're talking about, going from C# to Actionscript :).

Upvotes: 1

Related Questions