我们什么时候使用HashSet <> [duplicate](When do we use HashSet<> [duplicate])
这个问题在这里已经有了答案:
- 什么时候应该使用HashSet <T>类型? 10个答案
我有一个小样本。
//Class public class GetEntity { public string name1 { get; set; } public string name2 { get; set; } public GetEntity() { } }
和:
public void GetHash() { HashSet objHash = new HashSet(); GetEntity obj = new GetEntity(); obj.name1 = "Ram"; obj.name2 = "Shyam"; objHash.Add(obj); foreach (GetEntity objEntity in objHash) { Label2.Text = objEntity.name1.ToString() + objEntity.name2.ToString(); } }
代码工作正常。所有任务都是通过Dictionary和List.But完成的,但是我想知道什么时候使用HashSet <>,Dictionary <>或List <>。是否只有性能问题或其他我不明白的东西。谢谢。
This question already has an answer here:
- When should I use the HashSet<T> type? 11 answers
i have a small sample .
//Class public class GetEntity { public string name1 { get; set; } public string name2 { get; set; } public GetEntity() { } }
and:
public void GetHash() { HashSet objHash = new HashSet(); GetEntity obj = new GetEntity(); obj.name1 = "Ram"; obj.name2 = "Shyam"; objHash.Add(obj); foreach (GetEntity objEntity in objHash) { Label2.Text = objEntity.name1.ToString() + objEntity.name2.ToString(); } }
Code works fine.Same task is done through Dictionary and List.But i want to know when we use HashSet<> , Dictionary<> or List<>.Is there only performance issue or any other things which i dont understand.Thanks.
原文:https://stackoverflow.com/questions/8951242
最满意答案
只需删除MainWindow.xib,从info.plist和您的应用程序委托中移除参考。 然后,您可以在应用程序委托中创建自定义窗口的实例,并像应用程序委托当前那样调用
keyAndVisible
。Just delete MainWindow.xib remove refrences from info.plist and your app delegate. Then you can create an instance of your custom window in the app delegate and call
keyAndVisible
like the app delegate currently does.
相关问答
更多-
UIWindow和状态栏(UIWindow and Statusbar)[2023-10-25]
如果您设置根视图控制器怎么办? window.RootViewController = logonView; 如果您调用AddSubview而不是设置RootViewController,您应该收到警告“应用程序在应用程序启动结束时应该有一个根视图控制器”,并且某些内容(例如旋转)将无法正常工作。 否则,您可以设置logonView.Frame以考虑状态栏的大小。 What if you set the root view controller instead? window.RootVi ... -
优点,问题,添加另一个UIWindow到iOS应用程序的例子?(Advantages, problems, examples of adding another UIWindow to an iOS app?)[2021-10-12]
UIWindow可以浮动在其他UI元素上,如系统键盘。 解决你的最后一段:创建一个与主窗口相同框架的UIWindow 。 将其windowLevel属性设置为UIWindowLevelStatusBar 。 将其hidden属性设置为NO 。 A UIWindow can float above other UI elements like the system keyboard. To address your last paragraph: Make a UIWindow with the same f ... -
只需删除MainWindow.xib,从info.plist和您的应用程序委托中移除参考。 然后,您可以在应用程序委托中创建自定义窗口的实例,并像应用程序委托当前那样调用keyAndVisible 。 Just delete MainWindow.xib remove refrences from info.plist and your app delegate. Then you can create an instance of your custom window in the app delegat ...
-
我认为你的意思是“当你使用故事板时代码消失的地方。” 应用程序根据Info.plist中的“主要故事板文件基本名称”(UIMainStoryboardFile)键加载故事板,并从该故事板加载具有“Is initial view controller”切换集的视图控制器。 编辑:如评论中所述,以下代码(类似于基于xib的应用程序中的初始加载)将允许您在应用程序启动时按名称加载和显示故事板: -(BOOL)application:(UIApplication *)application didFinishLau ...
-
你正在做正确的事。 这是自定义窗口的方法。 如果你想一想,在IB中设置它就像麻烦一样。 如果您对键入这三行代码的前景感到迟钝,请考虑Xcode中代码片段库的便捷功能。 You are doing the right thing. That is the way to customize your window. Setting it in IB is just as cumbersome, if you think about it. If you are dulled by the prospect of ...
-
如何根据对另一个UIWindow的更改来更新UIWindow?(How to update UIWindow based on changes to another UIWindow?)[2023-02-16]
你可以做这样的事情: - (void)checkForExistingScreenAndInitializeIfPresent { if ([[UIScreen screens] count] > 1) { // Get the screen object that represents the external display. UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1]; ... -
UIWindow方向问题(两个UIWindows和横向模式)(UIWindow orientation issues (two UIWindows and landscape mode))[2023-04-30]
系统只会处理keyWindow旋转。 如果你有其他窗户,你必须自己处理旋转。 我也认为模态控制器是要走的路。 但是如果你真的想要处理旋转,可以看看其他“自定义窗口”库如何处理旋转。 警报视图是一个很好的例子: https://github.com/search?o=desc&q=uialertview&s=stars&type=Repositories&utf8=✓ The system will only handle rotation of your keyWindow. If you have oth ... -
子类化UIWindow(Subclassing UIWindow)[2022-04-28]
问题是我包括UIWindows - (void)sendEvent:(UIEvent *)事件方法,但没有调用super。 我打电话给它,一切都修好了。 The problem was I was including the UIWindows - (void)sendEvent:(UIEvent *)event method, but wasn't calling super on it. I called super on it and everything was fixed. -
它们来自项目中的MainWindow.xib(或类似)文件。 这是info.plist中的文件被设置为应用程序窗口。 当您的应用程序启动时,将加载此xib,并且视图控制器和窗口将被取消存档并加载。 They come from the MainWindow.xib (or similar) file in your project. This is the file that in your info.plist is set as the application window. When your app ...
-
用您自己的windowController实例覆盖makeWindowControllers //Lazy instantiation of window controller - (WindowController *)controller { if (!_controller) { _controller = [[WindowController alloc] initWithWindowNibName:@"Document"]; } return _controller; } ...