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