SoFunction
Updated on 2025-03-07

Example of using resource files in c#

It mainly uses the GetString and GetObject methods in the class. The return values ​​of both methods are Object type, and the required parameters are the unique identifier of the resource (the unique identifier used to add the resource when creating the resource).


First, instantiate an object of the ResourceManager class.

Copy the codeThe code is as follows:

//Create an instantiated object of the class

ResourceManager rm = new ResourceManager ( "Images" , ( ) ) ;

Then, you can call the method to use the resource.

Copy the codeThe code is as follows:

//Corresize type conversion
Icon ico = ((Icon)((""));//Get the icon
Image canceloff = ( ( Image ) ( ( "" ) ) ) ;//Get the picture
string str=((string)(("MyStr")));//Get string


This way the resources can be used. Of course, before using the resource, remember to import the resource in!