<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 何克勤 閱讀(4470) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 激情综合色五月丁香六月亚洲| 香蕉蕉亚亚洲aav综合| 可以免费观看一级毛片黄a| 在线亚洲午夜理论AV大片| 免费很黄无遮挡的视频毛片| 蜜臀98精品国产免费观看| www亚洲精品少妇裸乳一区二区| 久久亚洲AV成人无码软件| 亚洲人成网站在线播放2019| 日本道免费精品一区二区| 日韩一区二区在线免费观看| 久久av无码专区亚洲av桃花岛| 九九全国免费视频| 毛片免费在线视频| 亚洲精品中文字幕乱码| 中文字幕在线视频免费观看| 国产aa免费视频| 7777久久亚洲中文字幕| 午夜网站在线观看免费完整高清观看 | 免费观看激色视频网站(性色)| mm1313亚洲精品无码又大又粗| 色吊丝性永久免费看码 | 国产免费看插插插视频| 一级毛片免费播放试看60分钟| 亚洲中文字幕无码爆乳AV| 久久国产乱子伦精品免费一| 日韩精品亚洲aⅴ在线影院| 日本免费污片中国特一级| 亚洲一级片在线观看| 91老湿机福利免费体验| 亚洲va中文字幕无码久久| 男女拍拍拍免费视频网站| 国产精品亚洲mnbav网站| 一本岛v免费不卡一二三区| 久久青青草原亚洲AV无码麻豆| 免费专区丝袜脚调教视频| 国产精品久久久久久亚洲小说| 在线观看无码的免费网站| 亚洲精品成a人在线观看夫| 毛片免费观看视频| 中文字幕免费观看视频|