Init + private set accessors on the same property?

Similar to specifying a constructor to initialize your value, you can use a private backing field so that you can still take advantage of the init logic and allow initialization without a specific constructor public record Stuff { private int _myProperty; public int MyProperty { get => _myProperty; init => _myProperty = value; } public … Read more

How to use System.HashCode.Combine with more than 8 values?

As stated in the System.HashCode documentation, adding together hashes returned by successive HashCode.Combine calls is NOT the solution. While the static HashCode.Combine method overloads only allow up to 8 values, these are just convenience methods – to combine more, instantiate the HashCode class itself and use it as follows: public override int GetHashCode() { HashCode … Read more

HttpClient in using statement

The difference is that in the top loop, you’re creating 10 total HttpClient objects, using each once, and then disposing of each, while in the bottom, you’re creating just one HttpClient and reusing it. The point of the article is that it’s quite inefficient – and wholly unnecessary – to make a new HttpClient object … Read more

Except has similar effect to Distinct?

The documentation for the Except function states: Produces the set difference of two sequences by using the default equality comparer to compare values. The set difference of two sets is defined as the members of the first set that do not appear in the second set. The important word here is set, which is defined … Read more

How to get X509Certificate from certificate store and generate xml signature data?

As far as I know, certificates are not saved by XML Format , you should combine it by yourself. Is this what you want ? static void Main(string[] args) { X509Certificate2 cer = new X509Certificate2(); cer.Import(@”D:\l.cer”); X509Store store = new X509Store(StoreLocation.CurrentUser); store.Certificates.Add(cer); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection cers = store.Certificates.Find(X509FindType.FindBySubjectName, “My Cert’s Subject Name”, false); if (cers.Count>0) { … Read more

What is the lookup time complexity of HashSet(IEqualityComparer)?

A HashSet works via hashing (via IEqualityComparer.GetHashCode) the objects you insert and tosses the objects into buckets per the hash. The buckets themselves are stored in an array, hence the O(1) part. For example (this is not necessarily exactly how the C# implementation works, it just gives a flavor) it takes the first character of … Read more

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