我正在开发一个 C# 系统,一个类有一个返回System.Threading.Tasks.Task对象的函数,并且有一个属性System.TypeReturnType。
当 ReturnType 为 null 时,我知道该方法返回一个 Task 对象。但遗憾的是,没有办法知道实现该接口的类是否会返回 or ,Task<ReturnType>而Task<object>我需要获取此方法的结果。我认为最简单的方法是将 转换Task<T>为Task<object>以便我可以获得结果并使用 ReturnType 中的 Type 值处理它。
在不知道 T 类型的情况下如何将 a 转换Task<T>为?Task<object>
public interface ITaskFactory
{
ReadOnlyCollection<ParameterInfo> ParametersInfo { get; }
Type ReturnType { get; }
Task CreateTask (params object[] args);
}
Run Code Online (Sandbox Code Playgroud)
Task我需要获取我通过调用收到的返回的结果CreateTask()
请参阅: http: //dotnetfiddle.net/Bqwz0I
我需要支持在输入文本中使用非ascii字母的语言,所以我需要为FirstUnmatchedIndex实现StringComparison.CurrentCultureIgnoreCase.忽略套管并不是那么糟糕,但我不知道如何将组合符号转换为标准表示然后进行比较.所以这里有一些情况,函数应返回-1但返回别的东西....
encyclopædia = encyclopaedia
Archæology = Archaeology
ARCHÆOLOGY = archaeology
Archæology = archaeology
Weißbier = WEISSBIER
Run Code Online (Sandbox Code Playgroud)
如何知道char是否需要扩展并在需要时将每个char转换为扩展形式?
/// <summary>
/// Gets a first different char occurence index
/// </summary>
/// <param name="a">First string</param>
/// <param name="b">Second string</param>
/// <param name="compareSmallest">
/// If true, Returns the first difference found or -1 if the end of a string is reached without finding a difference.
/// IE, Return -1 if the smallest string is contained in the other.
/// Otherwise returns -1 only …Run Code Online (Sandbox Code Playgroud) 我有一个Silverlight业务应用程序项目.我还添加了一个Silverlight类库,可以从我的Silverlight应用程序中使用(当然).
在该库内(让我们称之为帮助)我有一个文件夹和一些小图像.在同一个库中,我有一个带有Image控件的子窗口,我需要在运行时更改源信息(代码隐藏).
当我添加互联网uri时,我发现一些在线的代码应该可以正常工作,比如flickr图像.所以我的问题是我写的Uri不对:(
Uri uri = new Uri("MyProj.Silverlight.Helper;images/error.png",UriKind.Relative);
ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
dlg.image.Source = img;
Run Code Online (Sandbox Code Playgroud)
我觉得我已经尽力了,显然我没有:(
编辑:我发现了很酷的帖子,但仍然没有运气.自Silverlight 2以来它有变化吗?