Skip to main content
 首页 » 编程设计

c#之如何更改 Resources.resx 模板

2024年02月13日15shihaiming

我想更改 Resources.resx 模板。

每当我添加一个新的资源文件时,它应该以下列形式显示自动生成的代码:

//------------------------------------------------------------------------------ 
// <auto-generated> 
//     This code was generated by a tool. 
//     Runtime Version:4.0.30319.296 
// 
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated. 
// </auto-generated> 
//------------------------------------------------------------------------------ 
 
namespace ProjectName.Properties 
{ 
 
 
/// <summary> 
///   A strongly-typed resource class, for looking up localized strings, etc. 
/// </summary> 
// This class was auto-generated by the StronglyTypedResourceBuilder 
// class via a tool like ResGen or Visual Studio. 
// To add or remove a member, edit your .ResX file then rerun ResGen 
// with the /str option, or rebuild your VS project. 
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 
**public** class Resources 
{ 
 
    private static global::System.Resources.ResourceManager resourceMan; 
 
    private static global::System.Globalization.CultureInfo resourceCulture; 
 
    [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 
    **public** Resources() 
    { 
    } 
 
    /// <summary> 
    ///   Returns the cached ResourceManager instance used by this class. 
    /// </summary> 
    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 
    **public** static global::System.Resources.ResourceManager ResourceManager 
    { 
        get 
        { 
            if ((resourceMan == null)) 
            { 
                global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LocBaml1.Properties.Resources", typeof(Resources).Assembly); 
                resourceMan = temp; 
            } 
            return resourceMan; 
        } 
    } 
 
    /// <summary> 
    ///   Overrides the current thread's CurrentUICulture property for all 
    ///   resource lookups using this strongly typed resource class. 
    /// </summary> 
    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 
    **public** static global::System.Globalization.CultureInfo Culture 
    { 
        get 
        { 
            return resourceCulture; 
        } 
        set 
        { 
            resourceCulture = value; 
        } 
    } 
} 

这里看到粗体部分(或者在** **之间)。我需要在主模板中将 internal 更改为 public 。 我怎样才能做到这一点?请提出建议。

请您参考如下方法:

您可以在资源文件中将访问修饰符更改为公共(public)。