@hilli_micha you can go Foreach(var item in list) even if there are no item, it will not throw an exception but you should check if list is not null and in some cases if list is binded UI and collection gets modified when you itereting it in foreach it will throw and exception so you should check to null and to List.ToList() and iterate
I have string query(script) for example "Create Table Test()" and I want to run this query every time when the App is launched and query size is different.
I'm looking for a diff algorithm that will produce results like SO's edit revisions page. I've more or less just started looking and I'm not opposed to doing it myself but I don't need to reinvent the wheel.
I'll be using C# 4.0. I'll basically have two strings, and old one and a new one. I...
Remember that hashcodes aren't a universal identifier. The same string might have a different hashcode if the same method is run at a different time, on a different .NET version, etc.
Compare the two hashcodes calculated by the same code, don't store a hashcode somewhere for later comparison
> The hash code itself is not guaranteed to be stable. Hash codes for identical strings can differ across versions of the .NET Framework and across platforms (such as 32-bit and 64-bit) for a single version of the .NET Framework. In some cases, they can even differ by application domain.
In WinForms, does Form.Close() immediate stop the execution of any code in that form? For example, if I wanna close one form before opening another from a click handler, can I just do this.Close(); new NextForm().Show();?
It should work. Remember that a method is a method, regardless of whether it's a click handler or not. To prevent the new NextForm().Show() from running, it would have to end the method execution, for example by throwing an exception.
However, note that what you're doing is instantiating a new object inside a method, then letting that method end. Effectively, you don't have any variable pointing to that form anymore.
@QPaysTaxes It is unlikely to do that - the GC is usually left to decide by itself when to react - and it's possible that a call to Show() registers the newly created form in some global dictionary somewhere so that it isn't disposed. But it's hard to be sure.
A more common approach for wizard-style navigation isn't to have each form instantiate the next one and go out of scope, but to have one orchestration view that manages the navigation between them.
LINQ methods in .Net
source.Where(x => condition)
.Select(x => projection)
were named to be consistent with LINQ query syntax in C# (and VB.NET)
from x in source
where condition
select projection
which was designed to be familiar to people who know SQL
SELECT projection
FROM source...
At the same time, Map is the standard terminology (in math, upon which basically everything in CS is based) and doesn't make the average person think of an action totally unrelated to what it actually does
Map doesn't mean anything to the average person either. It makes sense only if you already know what it does, in which case, you already know what it does.
Since I use LINQ to objects to manipulate lists and collections more than I do to manipulate DBs, I would also prefer Map to Select, but it doesn't really bother me.