1.使用ResourceManager

string st = Properties.Resources.ResourceManager.GetString(tableName);
value = Properties.Resources.ResourceManager.GetObject(fileName, Properties.Resources.Culture)

 

public static Bitmap GetImageByName(string imageName)
{
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
string resourceName = asm.GetName().Name + ".Properties.Resources";
var rm = new System.Resources.ResourceManager(resourceName, asm);
return (Bitmap)rm.GetObject(imageName);

}

 

2. 使用反射

var type = typeof(Properties.Resources);
var property = type.GetProperty(fileName, BindingFlags.Static| BindingFlags.NonPublic|BindingFlags.Public);
var value = property.GetValue(null, null);

相关文章:

  • 2022-12-23
  • 2021-07-25
  • 2022-01-07
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2022-01-26
猜你喜欢
  • 2021-12-06
  • 2021-07-18
  • 2022-12-23
  • 2021-08-01
  • 2021-11-06
  • 2021-06-19
  • 2022-12-23
相关资源
相似解决方案