When they break, they’re one of the more frustrating . In the example below, there’s a Text Block with a missing data context. (@Codeguru) https://github.com/paologutierrez/.net50/blob/master/nested-exception-handling.mdown LINQ makes it a lot easier to query data than if we use for/each loops with conditional logic like nested if blocks.Frustratingly, it won’t show errors in Visual Studio’s output window. But consider the code below, which uses LINQ-to-SQL to get a customer list: The code seems fine until we try to enumerate the collection.https://github.com/paologutierrez/.net50/blob/master/Logic errors happen when we don’t get the result we expected. That means 2 2 is 4 and “hello ” “world” is “hello world.” But what about “hello “ 2? The example below shows how forgetting that strings are immutable can lead us into a problem.They don’t always result in error messages because they’re not technically “bugs.” Instead, they’re problems with programming logic. (@amazedsaint) There’s another great example of an immutable string error here that results in the creation of 10,000 unwanted string variables.(@ericlippert) https://github.com/paologutierrez/.net50/blob/master/For any class, the default protection level is “internal.” For any member in that class, the default level is “private.” We can run into an issue when we forget those facts.When we declare “My Second Class” public, its variables don’t also become public.https://github.com/paologutierrez/.net50/blob/master/This problem is specific to C#. In C#, the programmer who writes the object decides whether the value assigned to it is a value or a reference to another object. At that point, we’ll get an “Object Disposed Exception.” That’s because link won’t actually perform the query until we attempt to enumerate the results.The example below shows a couple of unwanted surprises. To fix this, first convert your LINQ queries to a List using To List(), or to an array using To Array().
Rather than rely on a foreach loop or a for loop, use LINQ.If we want My First Class to be able to access the variables in My Second Class, we’ll need to set My First Class and the My Second Class variables to “public.” See this post for more details.(@Developer Drive) https://github.com/paologutierrez/.net50/blob/master/Apart from being a popular developer forum, this is also a common error.The code below will suck up 100% of the CPU core while the thread in Example() processes the https://github.com/paologutierrez/.net50/blob/master/Certain .
NET errors in the form of exceptions that can’t be foreseen and that originate from outside our control must be handled.
This can happen when we call an overridden method straight from the constructor of a base class. The program didn’t run into any code errors, but it gave us the wrong answer. We should have set the start Loop variable as 1, and end Loop as 11.