Sr. Strings usage

Source: Internet
Author: User
install string resource generator 1 [1]. 2.5 and run srgenerator. MSI. Add SR to your project. strings file, use . net in the existing . resx or Sr. strings File Settings Custom tool attribute: stringresourcetool or srcodegen .   For example: We defined a line in the SR. Strings file: Itemnotfoundmessage (key) = item not found in cache "R" N "tkey: {0} So we are applyingProgramYou can do this: This. primitivesresultstextbox. Text + = Sr. itemnotfoundmessage (selectitemform. itemkey) + "" R "N ";   In fact, the SR. itemnotfoundmessage is defined in the automatically generated Sr. CS file: Public static string itemnotfoundmessage (string key)
{
Return keys. getstring (Keys. itemnotfoundmessage, key );
}   This input method is helpful for us to unify the generation method of Error Descriptions in the application. For example, we can define the error description in the SR. Strings file: Lbs_request_cannotconnectserver = unable to connect to the remote lbs gateway server: {0} This can be used in actual calls: Catch (webexception ex)
{... SB. append ("<result resid =" "501"> "+ Sr. lbs_request_cannotconnectserver (_ URL) +" </result> "N "); ... }     Other Sr. Strings definition methods include:

Name

Value

Comments

Member on SR class

Notauthorized

You are not authorized, go away

String notauthorized {Get ;}

Argumentinvalid

Argument {0} is not valid

Argumentname

String argumentinvalid (Object argumentname );

Connectionbad

Connection server: {0}, database {1} invalid

Server, DB

String connectionbad (Object Server, object dB );

Otherstuff

This {0}, is undefined: {1}

String otherstuff (Object arg1, object arg2 );

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.