Sitecore 5.1.1 API

MainUtil.GetLong Method 

Gets the integer long value of a string.

[Visual Basic]
Public Shared Function GetLong( _
   ByVal obj As Object, _
   ByVal _default As Long _
) As Long
[C#]
public static long GetLong(
   object obj,
   long _default
);

Parameters

obj
A string or other object that can be converted to a long.
_default
A default value.

Return Value

The integer long value of a string.

Remarks

The default value is returned if the string is blank, null or is not an integer. No exception is thrown if the string is not an integer.

Example

  int i0 = MainUtil.GetInt("12", 0); // 12
  int i1 = MainUtil.GetInt("", 0); // 0
  int i2 = MainUtil.GetInt(null, 0); // 0
  int i3 = MainUtil.GetInt("123abc", 0); // 0

See Also

MainUtil Class | Sitecore Namespace