I'm currently learning C#, I am a beginner, so I'm not really familiar with the particularities of this language.
My problem is:
I have this piece of code which is supposed to convert an INTEGER to a CHAR and add 55 to the INTEGER to obtain the ASCII code for the hexadecimal when the user chooses a base between 11 and 16. When I use a simple "if" and "else" it works perfectly well, but for some reason, it doesn't work with the ternary operator
nConverti += (pNewbase > 10 && n >= 10) ?( n += 55 : (char)(n)): n;
nConverti += Depiler(ref unePile);
Just for presision I'm currently using Visual Studio 2022 version 17.8.5 and the framework's version is 4.8.09032.
I thank in advance anyone who will help me resolve this issue.
I already tried to read all the documentation I found about the ternary in C# but didn't found any solution, I even asked my college teacher who wasn't able to help me too. I also tried to update my framework and my visual studio but still doesn't change (even if I don't really think that the issue comes from there).
The ternary operator works as follows:
condition ? [true expression] : [false expression]using the assignment operator
+=inside theternary expression, which is not necessary and can lead to confusion better to write inif elseand its upto you