Teach explicit casting in "Cars, assemble" Concept

Hi there,

I am going through the C# track to prepare for a game jam with Unity, and I thought the Cars, Assemble exercise is missing an explanation on casting.

It is not a big deal, as it can be found on StackExchange quite easily, but I can imagine that beginners can benefit from one or two sentences about (int) like a C-style cast or an explicit conversion via Convert.ToInt32.

What do you think?

The exercise depends on the numbers concept, which has:

C# has two types of numeric conversions:

1. Implicit conversions: no data will be lost and no additional syntax is required.
2. Explicit conversions: data could be lost and additional syntax in the form of a _cast_ is required.

That maybe be too sparse then?

I think so. Coming from C++ it is not a big difference for me, but newcomers might need a little more. Especially since the other exercises down the concept path make heavy use of casting like the interest exercise.

1 Like

Maybe if we add a quick code example showing both conversions to that concept? That’d catch a student’s eye if they’re skimming like I’ve been doing on the C# syllabus. Personally, I take in the code examples first, then I read the nearby text, and then look at the code examples again.

1 Like

Yeah a code example could be good.

I made a PR.

P.S.: Thanks for all the work on the C# track, I’m happy that I can give back a bit to the community.

2 Likes

Sure! A lot of it was done by Mike Damay BTW, with me as the reviewer.