zoukankan      html  css  js  c++  java
  • C# add resource file and read resource files in console application

    1.Add resource file  Resource1.resx via add new item in Console Application project;

    2.Open Resource1.resx, Add Resource/Add Existing File, add multiple images;

    3.Initialize the ResourceManager instance,please pay attention to the ResourceManager's constructor parameter, baseName,it should include the namespace and resource.resx name;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Resources;
    using System.Text;
    using System.Threading.Tasks;
    using System.Reflection;
    using System.Globalization;
    using System.Collections;
    
    namespace ConsoleApp33
    {
        class Program
        {
            static void Main(string[] args)
            {
                ShowResourceFile();
                Console.ReadLine();
            }
    
            static void ShowResourceFile()
            {
                ResourceManager rm = new ResourceManager("ConsoleApp33.Resource1", Assembly.GetExecutingAssembly());
                ResourceSet resourcesSet = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
                if(resourcesSet!=null)
                {
                    foreach(DictionaryEntry de in resourcesSet)
                    {
                        Console.WriteLine($"Key={de.Key},Value={de.Value}");
                    }
                }
            }
        }
    }
  • 相关阅读:
    非递归前序遍历,效率高 和 中序遍历代码都相似
    递归-变量-堆栈-透彻理解
    Linux 进程管理
    5linux引导流程解析
    Linux 软件包管理
    vim
    Linux常用命令
    Linux 系统安装
    linux 应用和发展
    贴图、纹理、材质的区别是什么? 还有shader
  • 原文地址:https://www.cnblogs.com/Fred1987/p/13163906.html
Copyright © 2011-2022 走看看