Microsoft Ajax library cheat sheet (6): string and Object 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.

 

String. endswith (suffix)

Determines whether the string ends with the specified suffix.

 
VaRIstxt = mystring. endswith ("Some_file.txt",". Txt");
 
// Istxt = true

 

[S] String. Format (format, argS)

Replace the formatting items in the string with the corresponding parameter values. ARGs can be a single object or an array containing multiple items.

 
VaRUser = {
 
Firstname:'John',
Lastname:'Doe',
 
DOB:NewDate (1975, 1, 17 )};
 
VaRLabel = string. Format ("User name: {0} {1}, born {2: d }",
 
User. firstname, user. lastname, user. DOB ));
 
// Label = "User name: John Doe, born 02/17/1975"

 

[S]String. localeformat (format, argS)

The function is similar to string. Format (format, argS), but the format is related to the region settings.

 

String. startswith (prefix)

Determines whether the string starts with the specified prefix. See string. endswith (suffix ).

 

String. Trim ()

Returns a copy of the original string, but removes all blank characters (such as spaces or tabs) starting and ending with the original string.

VaRMystring ="A string";
 
Mystring = mystring. Trim ();
 
// Mystring = "a string"

 

String. trimend ()

Returns a copy of the original string, but removes all spaces (such as spaces or tabs) at the end of the original string.

 
VaRMystring ="A string";
 
Mystring = mystring. Trim ();
 
// Mystring = "a string"

 

String. trimstart ()

Returns a copy of the original string, but removes all blank characters (such as spaces or tabs) Starting with the original string.

 
VaRMystring ="A string";
 
Mystring = mystring. Trim ();
// Mystring = "a string"

 

[S]Object. GetType (Instance)

To return the type of the specified object, see object. gettypename (instance ).

 

[S]Object. gettypename (Instance)

Returns a fully qualified type string for the object at runtime.

 
Type. registernamespace ("Samples");
 
// Define and register a samples. Rectangle class.
 
Samples. Rectangle =Function(Width, height ){
 
This. _ Width = width;
 
This. _ Height = height;
 
}
Samples. Rectangle. registerclass ("Samples. rectangle");
 
VaRA =NewSamples. rectangle (200,100 );
 
VaRName = object. gettypename ();
 
VaRType = object. GetType ();
 
SYS. Debug. Trace ("The type name of object \" A \ "is :"+ Name );
 
SYS. Debug. tracedump (type );
 
/* The result is:
 
The type name of object "a" is: samples. rectangle
 
Tracedump {function}
 
Prototype {samples. Rectangle}
_ Typename: samples. rectangle
 
_ Class: True
 
*/
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.