Why is ‘char -> int’ promotion, but ‘char -> short’ is conversion (but not promotion)?

Historical motivation: C The idea of integral promotions dates all the way back to pre-standard C. When providing arguments to variadic functions (…) or to functions without a prototype, promotions are applied. I.e. calling: // function declaration with no prototype void mystery(); // … char c=”c”; mystery(c); // this promotes c to int // in … Read more

Cannot implicitly convert type ‘System.DateTime?’ to ‘System.DateTime’. An explicit conversion exists

You have 3 options: 1) Get default value dt = datetime??DateTime.Now; it will assign DateTime.Now (or any other value which you want) if datetime is null 2) Check if datetime contains value and if not return empty string if(!datetime.HasValue) return “”; dt = datetime.Value; 3) Change signature of method to public string ConvertToPersianToShow(DateTime datetime) It’s … Read more

Why does byte + byte = int?

The third line of your code snippet: byte z = x + y; actually means byte z = (int) x + (int) y; So, there is no + operation on bytes, bytes are first cast to integers and the result of addition of two integers is a (32-bit) integer.