小编Fra*_*s C的帖子

如何从HashSet <T>中检索实际项目?

我已经读过这个问题,为什么它不可能,但没有找到问题的解决方案.

我想从.NET中检索一个项目HashSet<T>.我正在寻找一种具有此签名的方法:

/// <summary>
/// Determines if this set contains an item equal to <paramref name="item"/>, 
/// according to the comparison mechanism that was used when the set was created. 
/// The set is not changed. If the set does contain an item equal to 
/// <paramref name="item"/>, then the item from the set is returned.
/// </summary>
bool TryGetItem<T>(T item, out T foundItem);
Run Code Online (Sandbox Code Playgroud)

使用这种方法搜索集合的项目将是O(1).从a中检索项目的唯一方法HashSet<T>是枚举所有O(n)项.

除了自己制作HashSet<T>或使用之外,我还没有找到解决这个问题的方法Dictionary<K, V>.还有其他想法吗?

注意:
我不想检查是否HashSet<T> …

.net c# hashset

77
推荐指数
4
解决办法
6万
查看次数

使用C#中的Windows默认编辑器打开图像

在我的C#应用​​程序中,我想启动默认图像编辑器来编辑图像.

当我使用System.Diagnostics.Process.Start("C:\\image.png")它时,使用Windows Photo Viewer打开图像文件.

当我在Windows资源管理器中右键单击图像文件时,会出现一个"编辑"菜单项,它启动Microsoft Paint(默认情况下).我想在我的应用程序中执行相同的操作(即使用默认图像编辑器打开文件).

我不想通过硬编码MS Paint Process.Start("mspaint.exe C:\\image.png").我更喜欢使用用户设置的默认图像编辑程序(可能与MS Paint不同).

有没有办法做到这一点?

谢谢弗兰克

.net c# windows image

4
推荐指数
1
解决办法
6753
查看次数

标签 统计

.net ×2

c# ×2

hashset ×1

image ×1

windows ×1