design-rationale

Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface?

风流意气都作罢 提交于 2020-01-09 11:14:29
问题 Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface? seemingly duplicate from here. but my idea is a bit different one, I just want to put a helper for my plugins(interface) shouldn't C# at least allow this idea? namespace MycComponent { public interface ITaskPlugin : ITaskInfo { string Description { get; } string MenuTree { get; } string MenuCaption { get; } void ShowTask(Form parentForm); void ShowTask(Form parentForm, Dictionary<string, object> pkColumns);

Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface?

久未见 提交于 2020-01-09 11:14:11
问题 Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface? seemingly duplicate from here. but my idea is a bit different one, I just want to put a helper for my plugins(interface) shouldn't C# at least allow this idea? namespace MycComponent { public interface ITaskPlugin : ITaskInfo { string Description { get; } string MenuTree { get; } string MenuCaption { get; } void ShowTask(Form parentForm); void ShowTask(Form parentForm, Dictionary<string, object> pkColumns);

Delphi: What is Application.Handle?

本小妞迷上赌 提交于 2019-12-17 21:43:57
问题 What is TApplication.Handle ? Where does it come from? Why does it exist? And most importantly: why do all forms have it as their parent window handle? The Delphi help says: TApplication.Handle Provides access to the window handle of the main form (window) of the application. property Handle: HWND; Description Use Handle when calling Windows API functions that require a parent window handle. For example, a DLL that displays its own top-level pop-up windows needs a parent window to display its

Why does the compiler think Environment.Exit can return?

混江龙づ霸主 提交于 2019-12-14 03:31:54
问题 Example code: switch(something) { case 0: System.Environment.Exit(0); case 1: // blah ... break; } It won't compile because the compiler thinks that execution can return from Exit(). The compiler is obviously wrong. No tricks. System.Environment.Exit() is the real one. Not only is it utterly illogical for System.Environment.Exit() to return, I traced the code and it eventually calls ExitProcess(exitCode); which can't return. 回答1: As far as the language is concerned, it can return. Yes, in

Why are drand48() and friends obsolete?

走远了吗. 提交于 2019-12-09 02:59:20
问题 After all, they seem superior to the standard libc rand(). Have I missed something? (I have spent some time searching for this online, and the only other instance of this question I could find was in the context of distribution bias and left unanswered.) The manual pages for rand() and drand48() also seem at odds. The first recommends the second, and the second states that it is obsolete and the first should be used. (Though, to be fair, a lot of people who understand the math behind PRNGs

Why does the standard library have find and find_if?

前提是你 提交于 2019-12-01 15:32:17
Couldn't find_if just be an overload of find ? That's how std::binary_search and friends do it... A predicate is a valid thing to find, so you could arrive at ambiguities. Consider find_if is renamed find , then you have: template <typename InputIterator, typename T> InputIterator find(InputIterator first, InputIterator last, const T& value); template <typename InputIterator, typename Predicate> InputIterator find(InputIterator first, InputIterator last, Predicate pred); What shall be done, then, with: find(c.begin(), c.end(), x); // am I finding x, or using x to find? Rather than try to come

Why does the standard library have find and find_if?

感情迁移 提交于 2019-12-01 14:19:42
问题 Couldn't find_if just be an overload of find ? That's how std::binary_search and friends do it... 回答1: A predicate is a valid thing to find, so you could arrive at ambiguities. Consider find_if is renamed find , then you have: template <typename InputIterator, typename T> InputIterator find(InputIterator first, InputIterator last, const T& value); template <typename InputIterator, typename Predicate> InputIterator find(InputIterator first, InputIterator last, Predicate pred); What shall be

Why are drand48() and friends obsolete?

£可爱£侵袭症+ 提交于 2019-12-01 03:36:49
After all, they seem superior to the standard libc rand(). Have I missed something? (I have spent some time searching for this online, and the only other instance of this question I could find was in the context of distribution bias and left unanswered.) The manual pages for rand() and drand48() also seem at odds. The first recommends the second, and the second states that it is obsolete and the first should be used. (Though, to be fair, a lot of people who understand the math behind PRNGs have issues with the man pages for these functions because they are poorly-worded and in some instances

Delphi: What is Application.Handle?

左心房为你撑大大i 提交于 2019-11-28 16:04:57
What is TApplication.Handle ? Where does it come from? Why does it exist? And most importantly: why do all forms have it as their parent window handle? The Delphi help says: TApplication.Handle Provides access to the window handle of the main form (window) of the application. property Handle: HWND; Description Use Handle when calling Windows API functions that require a parent window handle. For example, a DLL that displays its own top-level pop-up windows needs a parent window to display its windows in the application. Using the Handle property makes such windows part of the application, so