public object ReturnSqlScript(string token)
{
object script = "";
Type settingsType = typeof(Settings);
foreach (var propertyInfo in settingsType.GetProperties())
{
try
{
if (propertyInfo.Name.Contains(token))
{
script = propertyInfo.GetValue(propertyInfo, null);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
return script;
}
I have a bunch of SQL Scripts stored in Settings and this method allows me to get the Name of them by matching it to a token (eg. SqlScript2) however when I try to get the string value stored in SqlScript2 it will return “System.String SqlScript 2” rather than the value stored in it. Can I adjust the GetValue method to return my stored string?
Looking up documentation but have you tried?
I had already answered it here.