Rella
Rella

Reputation: 66995

How to declare number in C#?

In as3 I'd say

public var time:Number;

How to declare such in C#?

Upvotes: 0

Views: 1912

Answers (7)

Mukesh Sahu
Mukesh Sahu

Reputation: 11

If you are looking for small integer:

public int Number;   // This stores whole numbers. e.g., 3, 9 , -3.
public float Number; // This stores numbers with decimals. e.g., 3.27, -3.45

Upvotes: 1

Eric Mickelsen
Eric Mickelsen

Reputation: 10377

See "Types".

You probably want an int, long, float, double, decimal - or maybe DateTime or TimeSpan.

Upvotes: 4

s_hewitt
s_hewitt

Reputation: 4302

AS3 Number is most closely represented by a double in C#

public double time;

Number in AS3

Double in C#

Upvotes: 4

Timothy Carter
Timothy Carter

Reputation: 15795

Depending on the type you want:

public double time;

or you could use the DateTime struct provided by .NET

public DateTime time;

or really, you would probably want to create auto-properties for these like this:

public double Time {get;set;}

or

public DateTime Time {get;set;}

Upvotes: 2

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171589

C# has a a DateTime data type, so for dates I would create a variable like this:

public DateTime time;

This lets you do things like subtract dates, and make use of the TimeSpan structure.

Upvotes: 1

Femaref
Femaref

Reputation: 61497

public decimal time;

decimal depending of course on the type you want.

Upvotes: 1

jjnguy
jjnguy

Reputation: 138982

public long time;

This will create a new variable with the type long and the default value. (0)

Upvotes: 1

Related Questions