<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 134,comments - 22,trackbacks - 0

    可以使用 ResourceManager 類在運行時檢索“嵌入的資源”(即已經編譯到應用程序或類庫中的資源)。ResourceManager 類的每個實例都與一個程序集關聯并且管理對嵌入到該程序集中的資源的檢索。

    檢索資源

    1. 創建一個程序集引用,引用包含要訪問的資源的程序集。如果尚未加載包含資源的程序集,則必須在此時加載它。
    2. 創建 ResourceManager 類的實例以檢索資源。
    3. 指定嵌入文件的基名稱并提供對包含資源的程序集的引用。
      注意   嵌入的資源文件的基名稱是嵌入了資源文件的命名空間的名稱加上不帶任何擴展名的文件名。例如,myApplication 命名空間中名為 Resource1.resX 的文件的基名稱是 myApplication.Resource1。
    4. 調用 ResourceManager.GetString 方法ResourceManager.GetObject 方法以檢索資源。
      • 若要檢索“字符串”資源,請調用 GetString 方法。
      • 若要檢索其他類型的資源,請調用 GetObject 方法。通過 GetObject 方法檢索到的資源必須顯式轉換成對應的類型。

     demo1:

    // C#
    // Gets reference to the same assembly that 
    // contains the type that is creating the ResourceManager.
    System.Reflection.Assembly myAssembly;
    MyAssembly 
    = this.GetType().Assembly;

    // Gets reference to different assembly.
    System.Reflection.Assembly myOtherAssembly;
    myOtherAssembly 
    = System.Reflection.Assembly.Load("ResourceAssembly");

    // Creates the ResourceManager.
    System.Resources.ResourceManager myManager = new 
       System.Resources.ResourceManager(
    "ResourceNamespace.myResources"
       myAssembly);

    // Retrieves String and Image resources.
    System.String myString;
    System.Drawing.Image myImage;
    myString 
    = myManager.GetString("StringResource");
    myImage 
    = (System.Drawing.Image)myManager.GetObject("ImageResource");

     

     

    demo2:

    using System;
    using System.Resources;
    using System.Threading;
    using System.Reflection;
    using System.Globalization;
    class ResourcesExample 
    {
        
    public static void Main() 
        
    {
            
    // Create resource manager to retrieve resources.
            ResourceManager rm = new ResourceManager("resourceManager.Application"
                Assembly.GetExecutingAssembly());

        
    // Get the culture of the currently executing thread.
        
    // The value of ci will determine the culture of
        
    // the resources that the resource manager retrieves.
        CultureInfo ci = Thread.CurrentThread.CurrentCulture;

        
        
    // Retrieve the value of the string resource named 
        
    // "welcome", localized for the culture specified by ci.
        String str = rm.GetString("welcome"System.Globalization.CultureInfo.CurrentCulture);
        Console.WriteLine(str);
        }

    }

    資源文件必須寫成,程序集名字.資源文件名不包括擴展名

    posted on 2009-03-30 19:49 何克勤 閱讀(4468) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品国产成人| 亚洲日本国产乱码va在线观看| 亚洲欧美中文日韩视频| 亚洲精品视频在线免费| 亚洲毛片无码专区亚洲乱| 久久久精品2019免费观看| 亚洲国产高清视频| 222www免费视频| 亚洲永久在线观看| 午夜视频在线观看免费完整版| 亚洲成熟丰满熟妇高潮XXXXX| 免费视频中文字幕| 看Aⅴ免费毛片手机播放| 亚洲午夜精品久久久久久浪潮 | 久久乐国产精品亚洲综合| www在线观看免费视频| 亚洲乱色熟女一区二区三区丝袜| 国产日韩一区二区三免费高清| 亚洲天堂中文字幕| 在线看片韩国免费人成视频| 亚洲精品无码专区在线| 亚洲日本一区二区三区在线不卡| 久久免费视频网站| 亚洲av极品无码专区在线观看| 精品久久久久久久免费加勒比| 免费一级全黄少妇性色生活片| 亚洲日韩欧洲无码av夜夜摸| 色猫咪免费人成网站在线观看| 99999久久久久久亚洲| 亚洲av日韩片在线观看| 日本视频免费高清一本18| 久久综合久久综合亚洲| 亚洲福利视频一区二区| 一级毛片免费观看不卡的| 亚洲久悠悠色悠在线播放| 亚洲av无码成人精品区| 亚洲电影在线免费观看| 成年免费大片黄在线观看com| 亚洲黄色三级网站| 亚洲国产一级在线观看| 国产成人精品免费午夜app|