public class SettingsBase
{
}
public class SettingsDerived : SettingsBase
{
}
public class yyy
{
public void StartUpMethod(Action<SettingsDerived> settings)
{
//something goes here..
SettingsDerived ds = new SettingsDerived();
settings(ds);//take out SettingsDerived properties..
SettingsBase bs = Method1(settings as Action<SettingsBase>);//as operator returns null because settings is not of type Action<SettingsBase>
//again do something on s based on extracted SettingsDerived
}
public SettingsBase Method1(Action<SettingsBase> settings)
{
SettingsBase s = new SettingsBase();
//something goes here
settings(s);
return s;
}
}
どうすればこれを達成できますか? または回避策はありますか?