mscorlib(4.0.0.0) API with additions
Int64.cs
4 using System.Security;
5 
6 namespace System
7 {
10  [ComVisible(true)]
11  [__DynamicallyInvokable]
13  {
14  internal long m_value;
15 
17  [__DynamicallyInvokable]
18  public const long MaxValue = 9223372036854775807L;
19 
21  [__DynamicallyInvokable]
22  public const long MinValue = -9223372036854775808L;
23 
30  public int CompareTo(object value)
31  {
32  if (value == null)
33  {
34  return 1;
35  }
36  if (value is long)
37  {
38  long num = (long)value;
39  if (this < num)
40  {
41  return -1;
42  }
43  if (this > num)
44  {
45  return 1;
46  }
47  return 0;
48  }
49  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt64"));
50  }
51 
55  [__DynamicallyInvokable]
56  public int CompareTo(long value)
57  {
58  if (this < value)
59  {
60  return -1;
61  }
62  if (this > value)
63  {
64  return 1;
65  }
66  return 0;
67  }
68 
73  [__DynamicallyInvokable]
74  public override bool Equals(object obj)
75  {
76  if (!(obj is long))
77  {
78  return false;
79  }
80  return this == (long)obj;
81  }
82 
87  [NonVersionable]
88  [__DynamicallyInvokable]
89  public bool Equals(long obj)
90  {
91  return this == obj;
92  }
93 
96  [__DynamicallyInvokable]
97  public override int GetHashCode()
98  {
99  return (int)this ^ (int)(this >> 32);
100  }
101 
104  [SecuritySafeCritical]
105  [__DynamicallyInvokable]
106  public override string ToString()
107  {
108  return Number.FormatInt64(this, null, NumberFormatInfo.CurrentInfo);
109  }
110 
114  [SecuritySafeCritical]
115  [__DynamicallyInvokable]
116  public string ToString(IFormatProvider provider)
117  {
118  return Number.FormatInt64(this, null, NumberFormatInfo.GetInstance(provider));
119  }
120 
126  [SecuritySafeCritical]
127  [__DynamicallyInvokable]
128  public string ToString(string format)
129  {
130  return Number.FormatInt64(this, format, NumberFormatInfo.CurrentInfo);
131  }
132 
139  [SecuritySafeCritical]
140  [__DynamicallyInvokable]
141  public string ToString(string format, IFormatProvider provider)
142  {
143  return Number.FormatInt64(this, format, NumberFormatInfo.GetInstance(provider));
144  }
145 
155  [__DynamicallyInvokable]
156  public static long Parse(string s)
157  {
158  return Number.ParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo);
159  }
160 
175  [__DynamicallyInvokable]
176  public static long Parse(string s, NumberStyles style)
177  {
178  NumberFormatInfo.ValidateParseStyleInteger(style);
179  return Number.ParseInt64(s, style, NumberFormatInfo.CurrentInfo);
180  }
181 
192  [__DynamicallyInvokable]
193  public static long Parse(string s, IFormatProvider provider)
194  {
195  return Number.ParseInt64(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider));
196  }
197 
213  [__DynamicallyInvokable]
214  public static long Parse(string s, NumberStyles style, IFormatProvider provider)
215  {
216  NumberFormatInfo.ValidateParseStyleInteger(style);
217  return Number.ParseInt64(s, style, NumberFormatInfo.GetInstance(provider));
218  }
219 
225  [__DynamicallyInvokable]
226  public static bool TryParse(string s, out long result)
227  {
228  return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
229  }
230 
241  [__DynamicallyInvokable]
242  public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out long result)
243  {
244  NumberFormatInfo.ValidateParseStyleInteger(style);
245  return Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result);
246  }
247 
251  {
252  return TypeCode.Int64;
253  }
254 
259  [__DynamicallyInvokable]
261  {
262  return Convert.ToBoolean(this);
263  }
264 
268  [__DynamicallyInvokable]
270  {
271  return Convert.ToChar(this);
272  }
273 
277  [__DynamicallyInvokable]
279  {
280  return Convert.ToSByte(this);
281  }
282 
286  [__DynamicallyInvokable]
288  {
289  return Convert.ToByte(this);
290  }
291 
295  [__DynamicallyInvokable]
297  {
298  return Convert.ToInt16(this);
299  }
300 
304  [__DynamicallyInvokable]
306  {
307  return Convert.ToUInt16(this);
308  }
309 
313  [__DynamicallyInvokable]
315  {
316  return Convert.ToInt32(this);
317  }
318 
322  [__DynamicallyInvokable]
324  {
325  return Convert.ToUInt32(this);
326  }
327 
331  [__DynamicallyInvokable]
333  {
334  return this;
335  }
336 
340  [__DynamicallyInvokable]
342  {
343  return Convert.ToUInt64(this);
344  }
345 
349  [__DynamicallyInvokable]
351  {
352  return Convert.ToSingle(this);
353  }
354 
358  [__DynamicallyInvokable]
360  {
361  return Convert.ToDouble(this);
362  }
363 
367  [__DynamicallyInvokable]
369  {
370  return Convert.ToDecimal(this);
371  }
372 
377  [__DynamicallyInvokable]
379  {
380  throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Int64", "DateTime"));
381  }
382 
387  [__DynamicallyInvokable]
388  object IConvertible.ToType(Type type, IFormatProvider provider)
389  {
390  return Convert.DefaultToType(this, type, provider);
391  }
392  }
393 }
float ToSingle(IFormatProvider provider)
Converts the value of this instance to an equivalent single-precision floating-point number using the...
Converts a base data type to another base data type.
Definition: Convert.cs:10
int CompareTo(object value)
Compares this instance to a specified object and returns an indication of their relative values.
Definition: Int64.cs:30
static double ToDouble(object value)
Converts the value of the specified object to a double-precision floating-point number.
Definition: Convert.cs:3189
override int GetHashCode()
Returns the hash code for this instance.
Definition: Int64.cs:97
TypeCode GetTypeCode()
Returns the T:System.TypeCode for value type T:System.Int64.
Definition: Int64.cs:250
double ToDouble(IFormatProvider provider)
Converts the value of this instance to an equivalent double-precision floating-point number using the...
Represents a 64-bit signed integer.
Definition: Int64.cs:12
bool ToBoolean(IFormatProvider provider)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specif...
TypeCode
Specifies the type of an object.
Definition: TypeCode.cs:9
const long MaxValue
Represents the largest possible value of an Int64. This field is constant.
Definition: Int64.cs:18
static float ToSingle(object value)
Converts the value of the specified object to a single-precision floating-point number.
Definition: Convert.cs:2982
Definition: __Canon.cs:3
static long Parse(string s, NumberStyles style, IFormatProvider provider)
Converts the string representation of a number in a specified style and culture-specific format to it...
Definition: Int64.cs:214
The exception that is thrown for invalid casting or explicit conversion.
override bool Equals(object obj)
Returns a value indicating whether this instance is equal to a specified object.
Definition: Int64.cs:74
char ToChar(IFormatProvider provider)
Converts the value of this instance to an equivalent Unicode character using the specified culture-sp...
Provides a mechanism for retrieving an object to control formatting.
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
static long Parse(string s, IFormatProvider provider)
Converts the string representation of a number in a specified culture-specific format to its 64-bit s...
Definition: Int64.cs:193
DateTime ToDateTime(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.DateTime using the specified culture-sp...
static NumberFormatInfo CurrentInfo
Gets a read-only T:System.Globalization.NumberFormatInfo that formats values based on the current cul...
sbyte ToSByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture...
Defines a generalized type-specific comparison method that a value type or class implements to order ...
Definition: IComparable.cs:8
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
Definition: NumberStyles.cs:10
bool Equals(long obj)
Returns a value indicating whether this instance is equal to a specified T:System....
Definition: Int64.cs:89
static char ToChar(object value)
Converts the value of the specified object to a Unicode character.
Definition: Convert.cs:670
static long Parse(string s)
Converts the string representation of a number to its 64-bit signed integer equivalent.
Definition: Int64.cs:156
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static bool ToBoolean(object value)
Converts the value of a specified object to an equivalent Boolean value.
Definition: Convert.cs:457
decimal ToDecimal(IFormatProvider provider)
Converts the value of this instance to an equivalent T:System.Decimal number using the specified cult...
int ToInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit signed integer using the specified cultur...
static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
Gets the T:System.Globalization.NumberFormatInfo associated with the specified T:System....
const long MinValue
Represents the smallest possible value of an Int64. This field is constant.
Definition: Int64.cs:22
static ushort ToUInt16(object value)
Converts the value of the specified object to a 16-bit unsigned integer.
Definition: Convert.cs:1707
object ToType(Type conversionType, IFormatProvider provider)
Converts the value of this instance to an T:System.Object of the specified T:System....
static sbyte ToSByte(object value)
Converts the value of the specified object to an 8-bit signed integer.
Definition: Convert.cs:909
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
string ToString(string format, IFormatProvider provider)
Converts the numeric value of this instance to its equivalent string representation using the specifi...
Definition: Int64.cs:141
ushort ToUInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified cult...
static long Parse(string s, NumberStyles style)
Converts the string representation of a number in a specified style to its 64-bit signed integer equi...
Definition: Int64.cs:176
static uint ToUInt32(object value)
Converts the value of the specified object to a 32-bit unsigned integer.
Definition: Convert.cs:2235
override string ToString()
Converts the numeric value of this instance to its equivalent string representation.
Definition: Int64.cs:106
short ToInt16(IFormatProvider provider)
Converts the value of this instance to an equivalent 16-bit signed integer using the specified cultur...
static decimal ToDecimal(object value)
Converts the value of the specified object to an equivalent decimal number.
Definition: Convert.cs:3394
long ToInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit signed integer using the specified cultur...
The exception that is thrown when one of the arguments provided to a method is not valid.
string ToString(IFormatProvider provider)
Converts the numeric value of this instance to its equivalent string representation using the specifi...
Definition: Int64.cs:116
int CompareTo(long value)
Compares this instance to a specified 64-bit signed integer and returns an indication of their relati...
Definition: Int64.cs:56
static byte ToByte(object value)
Converts the value of the specified object to an 8-bit unsigned integer.
Definition: Convert.cs:1186
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: IEquatable.cs:6
static short ToInt16(object value)
Converts the value of the specified object to a 16-bit signed integer.
Definition: Convert.cs:1452
Specifies that the class can be serialized.
ulong ToUInt64(IFormatProvider provider)
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified cult...
static ulong ToUInt64(object value)
Converts the value of the specified object to a 64-bit unsigned integer.
Definition: Convert.cs:2727
static int ToInt32(object value)
Converts the value of the specified object to a 32-bit signed integer.
Definition: Convert.cs:1974
byte ToByte(IFormatProvider provider)
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified cultu...
Defines methods that convert the value of the implementing reference or value type to a common langua...
Definition: IConvertible.cs:9
static bool TryParse(string s, out long result)
Converts the string representation of a number to its 64-bit signed integer equivalent....
Definition: Int64.cs:226
Provides functionality to format the value of an object into a string representation.
Definition: IFormattable.cs:8
uint ToUInt32(IFormatProvider provider)
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified cult...
string ToString(string format)
Converts the numeric value of this instance to its equivalent string representation,...
Definition: Int64.cs:128
static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out long result)
Converts the string representation of a number in a specified style and culture-specific format to it...
Definition: Int64.cs:242
Provides culture-specific information for formatting and parsing numeric values.