C# 获取版本号、资源文件、全局配置Settings.Settings

1:Properties->AssemblyInfo.cs-[assembly: AssemblyVersion("1.0.0.0")]

string Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); // 返回 1.0.0.0


2:Properties->Resources.resx

 System.Resources.ResourceManager rs = new System.Resources.ResourceManager("RedisSeverDemo.Properties.Resources", typeof(Resources).Assembly);
  //此处的 RedisSeverDemo.Properties.Resources 表示:命名空间.资源类名
 var title = rs.GetString("version3");//获取资源名为version的字符串
 var img = rs.GetObject("aaa");//获取资源名为aaa的图片

 pictureBox1.Image = img as Bitmap;

或者

string con = Properties.Resources.version3;


3:Properties->Settings.settings

string con = Properties.Settings.Default.demoStr;

猜你喜欢

转载自blog.csdn.net/xml714467338/article/details/73558498