我在函数Doit(我正在运行.Net 3.5)中使用此代码获取这些错误:
错误1: The best overloaded method match for 'LoadPref<A>(string, System.Func<string,A>, A)' has some invalid arguments
错误2: Argument '2': cannot convert from 'method group' to 'System.Func<string,A>'
class A : SomeObject
{
}
static class Utilities
{
private T LoadPref<T>( string key, Func<string, T> loaderFunc, T defaultValue )
{
if ( Prefs.HasKey( key ) )
{
return loaderFunc( Prefs.GetString( key ) );
}
return defaultValue;
}
private T LoadAsset<T>( string assetPath ) where T : SomeObject
{
return (T)LoadAssetInSomeWay( assetPath );
}
private void Doit()
{
A asset = LoadPref<A>( "key", LoadAsset, null );
}
}
Run Code Online (Sandbox Code Playgroud)
谁知道什么是错的?
| 归档时间: |
|
| 查看次数: |
102 次 |
| 最近记录: |