When should I use a struct instead of a class?

MSDN has the answer: Choosing Between Classes and Structures. Basically, that page gives you a 4-item checklist and says to use a class unless your type meets all of the criteria. Do not define a structure unless the type has all of the following characteristics: It logically represents a single value, similar to primitive types … Read more

What is the difference between String.Empty and “” (empty string)?

In .NET prior to version 2.0, “” creates an object while string.Empty creates no objectref, which makes string.Empty more efficient. In version 2.0 and later of .NET, all occurrences of “” refer to the same string literal, which means “” is equivalent to .Empty, but still not as fast as .Length == 0. .Length == … Read more

What is “.NET Core”?

From the .NET blog Announcing .NET 2015 Preview: A New Era for .NET: .NET Core has two major components. It includes a small runtime that is built from the same codebase as the .NET Framework CLR. The .NET Core runtime includes the same GC and JIT (RyuJIT), but doesn’t include features like Application Domains or … Read more

How to specify the port an ASP.NET Core application is hosted on?

In ASP.NET Core 3.1, there are 4 main ways to specify a custom port: Using command line arguments, by starting your .NET application with –urls=[url]: dotnet run –urls=http://localhost:5001/ Using appsettings.json, by adding a Urls node: { “Urls”: “http://localhost:5001” } Using environment variables, with ASPNETCORE_URLS=http://localhost:5001/. Using UseUrls(), if you prefer doing it programmatically: public static class … Read more

Warning: Found conflicts between different versions of the same dependent assembly

This warning means that two projects reference the same assembly (e.g. System.Windows.Forms) but the two projects require different versions. You have a few options: Recompile all projects to use the same versions (e.g. move all to .Net 3.5). This is the preferred option because all code is running with the versions of dependencies they were … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)