C # resource file operation example-create resources and read Resources

Source: Internet
Author: User
1. Create a Windows Application Program Useres, used to call resources.
Create a new class library res to store resource files.

2. Add the resource file res. resx to the RES project.
Add three resources:
Hongye. ICO
Girl.gif
String strtest value: Hello World
3. Change the res. resx access modifier from internal to public.
This can be called in other projects.
4. Add RES project reference for useres.
5. Read resource code

Using System;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. LINQ;
Using System. text;
Using System. Windows. forms;

NamespaceUseres
{
Public Partial ClassFrmmain: Form
{
PublicFrmmain ()
{
Initializecomponent ();
}

Private   Void Btnread_click ( Object Sender, eventargs E)
{
// Read Resources
Icon = Res. res. Hongye;
Bitmap bitmap = Res. res. girl;
String Strtest = Res. res. strtest;
//
This . Icon = Icon;
This . Picturebox1.image = Bitmap;
MessageBox. Show (strtest );
}
}
}

Original article: http://www.it100.info/res.html
Running result

Source: http://dotnet.5d6d.com/thread-318-1-1.html

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.