It doesn’t have to be perfect to work. In fact sometimes getting the result is more important than how it is acheived.
As part of my journey I undertook to complete the FreeCodeCamp course Foundational C# with Microsoft

The course collates various modules sourced from the Microsoft Learn catalogue, to build a rudimentary umderstanding of C#, with certification offerred at the end.
In one of the sections dealing with “if, else if, if” statement the second challenge threw me for a while. My mind went blank, so i walked away from the challenge for a day or two.

Then I had an epiphany. How would I solve the challenge using an Excel formula?
With a little thought it was obvious that a nested “if” statement would be one way of providing a solution!

=if(B6="Admin","Welcome admin",if(B6="Manager","welcome manager","you do not have permission"))</b>

In C# this translates to:

string B6 = ""; // Assign the value of B6 here

if (B6 == "Admin")
{
    Console.WriteLine("Welcome admin");
}
else if (B6 == "Manager")
{
    Console.WriteLine("Welcome manager");
}
else
{
    Console.WriteLine("You do not have permission");
}

It might not be a direct analogy, but drawing on my experience in another domain and working through the steps I would take helped me navigate through this particular syntax of C#

I may not be able to use this approch for every situation - if Excel formulas could do all programming tasks then arguably we wouldnt have the plethora of coding languages that we do - but maybe those decades working on them (not to mention Lotus 123!) havent been wasted after all!

Speadsheets are Code

Microsoft’s New Programming Language for Excel Now Turing Complete


<
Previous Post
Tracing the Source
>
Next Post
Workings