Microsoft Ajax library cheat sheet (5): number and Error Type Extension

Source: Internet
Author: User

The original cheat sheet (PDF version) is here to download: http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip

Original copyright statement:

Copyright (c) 2004-2006, Milan negovan http://www.AspNetResources.comAll rights reserved. redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * redistributions of source code must retain the above copyright notice, this list of conditions and the following disclawing. * redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclawing in the documentation and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. this software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited, the implied warranties of merchantability and fitness for a special purpose are disclaimed. in no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

 

NOTE: If [s] is marked as a static method, it can be used without instantiating an object.

 

Number. Format (Format)

Format the number with the specified format (region setting is irrelevant ).

 

Number. localeformat (Format)

Format the number with the specified format (related to region settings ).

 

Supported formats

    1. P: Convert the number into a percentage string (e.g.:-1,234.56%)
    2. D: Convert the number into a decimal string without a comma separator (e.g.:-1234.56)
    3. C: convert a number into a currency amount (e.g.: (Jun 1,234.56 ))
    4. N: concatenate digits into commas (,) to separate them (-D, DDD, DDD... ") Form (e.g.:-1,234.56)

 

[S] Number. parselocale (value)

Parses the local number represented by a string into the corresponding number type. Use SYS. cultureinfo. currentculture to obtain the current region attribute.

 

[S]Number. parseinvariant (value)

Parses the local number represented by a string into the corresponding floating point number type. Value can contain commas (,) or plus or minus (+.

 
VaRA =NewNumber ();
 
A = number. parseinvariant ("4");
 
VaRB =NewNumber (2 );
 
VaRC = number. parseinvariant ("1.53") + A + B;
 
// C = 7.53

 

Error-related methods

  1. [S]Error. Argument: Creates a sys. argumentexception type exception based on the specified exception information and invalid parameters.
  2. [S]Error. argumentnull: Create a sys. argumentnullexception type exception based on the specified exception information and the null parameter.
  3. [S]Error. argumenttype: Create a sys. argumenttypeexception type exception based on the specified exception information, expected parameter type, and actual parameter type.
  4. [S]Error. argumentundefined: Create a sys. argumentundefinedexception type exception based on the specified exception information and the defined parameter.
  5. [S]Error. Create: Creates an error object based on the specified exception information.
  6. [S]Error. invalidoperation: Create a sys. invalidoperationexception type exception based on the specified exception information and the parameter that causes the exception.
  7. [S]Error. notimplemented: Create a sys. notimplementedexception type exception based on the specified exception information.
  8. [S]Error. argumentoutofrange: Create a sys. argumentoutofrangeexception type exception based on the specified exception information and the parameter that causes the exception.
  9. [S]Error. parametercount: Create a sys. parametercountexception type exception based on the specified exception information.
  10. Error. popstackframe: Update the filename and linenumber fields of the error instance to the location when the error is thrown, rather than the location when the error is created.
 
// Throw a standard exception type
 
VaRErr = Error. argumentnull ("Input","A parameter was undefined .");
 
ThrowErr;
 
// Throw a generic error with a message and associated errorinfo object.
 
VaRErrorinfoobj = {Name:"Somenamespace. someexceptionname",
 
Someerrorid:"436"};
 
VaRErr = Error. Create ("A Test message", Errorinfoobj );
  throw  err; 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.