I'm programming in C#, but I don't know -- see below, using Visual Studio 2022 (see below for the version), and I want to know how to best detect that an optional class constructor's parameter has been specified when called by the the new call. I know about using a default value assignment to the parameter, but when all values are valid, then there isn't one that can be used to detect the 'missing' parameter, i.e.:
bool bLogical = false
Instead I use object bLogical = null and then test if bLogical is null, fair enough, but then I also have to check that the value passed in is an acceptable type, which could be byte, short, int, etc., so the tests and conversions make all of this more complex. Is there a simpler yet comprehensive way to do all of this that will let the compiler and the built-in types do more of the work?
Here is some of what shows in VS' Help > About:
Microsoft Visual Studio Community 2022
Version 17.14.37 (July 2026)
VisualStudio.17.Release/17.14.37+37516.0.-july.2026-
Microsoft .NET Framework
Version 4.8.09221
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA092
Microsoft Visual C++ 2022
C# Tools 4.14.0-3.26364.8+3f38462646eca9ed0f89313d36a22e031920552d
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual Studio IntelliCode 2.2
Visual Studio Tools for Unity 17.14.1.0