Home » Archive by category "c#"

CefSharp Offscreen [Why do I have so many instances of Chromium?]

I’ve been using the CefSharp.Offscreen library to drive the Chromium browser for a couple of months now.  While the code I’ve been working on has been working correctly, I could never figure out why so many instances of Chromium are left dangling in my task manager.  Oh, they’d all go away once I exited the application, but then it would take a very long time for my application to completely close because there were so many instances of Chromium hanging around.

This past week, I finally figured out how to keep the number of Chromium instances in line with the number of off-screen browser windows I was actually creating.

image Continue reading “CefSharp Offscreen [Why do I have so many instances of Chromium?]”

String and StringBuilder

A couple of weeks ago, we discussed Value types and Reference types where we said that a reference type points to the value it represents and a value type is the value it represents.

This has implications when we work with the assignment operator because when you assign a reference type and change the content of what it is pointing to, both variables get changed because they are both pointing to the same location in memory.  If you do this with a value type, only the one you change sees the change because you are working with a copy.

Continue reading “String and StringBuilder”

Value Type vs Reference Type

It is amazing to me how few programmers understand the fundamentals of how variables work.  Not just in .NET or C# specifically, but in every language they work in.  It amazes me for two reasons.  First, I don’t think I could program if I didn’t understand what was physically happening as a result of the code I was writing.  Not knowing how the variables relate to the memory that they use would be, to me, a major limitation.  But it also amazes me because I don’t think anyone can program intelligently until they do know what is happening.

So, I’ll start from the outside and move in to what’s happening in memory.

What is A Value Type

The first question we need to qualify is, “What types in .NET are referred to as Value types?  Common value types are int, double, float, decimal, and bool.  What we ypically refer to as “primitives”.  But, there are other types that are also value types.  Enums, structs, and DateTime(because it is a struct) are also value types. Continue reading “Value Type vs Reference Type”

C# Properties Get and Set

My son is learning to program.  Last week he asked me to explain C# properties get and set and, as it turns out, it looks like many others are asking for the same.  So, I’ve decided to spend the time on this post, explaining getters and setters in about as much detail as one can expect.

So here it goes…

Continue reading “C# Properties Get and Set”