When you think of C# and web automation, your mind might first leap to Selenium. But what if I told you there’s a headless browser automation tool with a slick, modern API, powered by the Chrome DevTools Protocol, and it’s *blazingly fast*? Enter: PuppeteerSharp.
Tag: c#
-
Understanding IndexOutOfRangeException and ArgumentOutOfRangeException
You’ve received the following error: Index was outside the bounds of the array with an IndexOutOfRangeException or you received:
An exception of type ‘System.ArgumentOutOfRangeException’ occurred in mscorlib.dll but was not handled in user code Additional information: Index was out of range. Must be non-negative and less than the size of the collection with an ArgumentOutOfRangeException.
So what gives? Here is what you need to know.
- What is IndexOutOfRangeException error message: Index was outside the bounds of the array
- What is An exception of type System.ArgumentOutOfRangeException
- Type: System.ArgumentOutOfRangeException
- Encountering the ArgumentOutOfRangeExceptionException Type
- What is IndexOutOfRangeException: Index was outside the bounds of the array
- ArgumentOutOfRangeException class
- Frequently Asked Questions
-
How to Truncate a string in C#
Leveraging C#’s substring to truncate a string, I am going to demonstrate how to create a string extension with a new re-usable function called Truncate.
-
C# Convert any value to a boolean
In these examples, I will demonstrate how to convert a string to boolean and an integer to boolean using C#.
You accept a variety of user input that you want to intelligently convert to a valid boolean variable. E.g. string of On = true. No = false.
-
Catching multiple exceptions with C#
Exception handling with Try/catch blocks are a part of my everyday life. But I’m not a fan of catching all exceptions. I prefer handling only the ones I expect to be thrown in specific situations where I want to explicitly do catching multiple exceptions. Of course I can accomplish this with multiple catch blocks, but when they all do common things I would like a simpler way to avoid code duplication. Another great example would be how to use C# Convert any value to a boolean.