This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17466|Reply: 0

[Source] Regarding ternary operators, there is an error that cannot determine the type of conditional expression

[Copy link]
Posted on 11/3/2015 5:15:48 PM | | |
Error 1 Unable to determine the type of conditional expression

When we use ternary operators, we often encounter if? If the following two data types are inconsistent, this or that error will often be prompted.
The solution is to convert both types to object types, and then perform ternary operators

Code:

            var s = site as object;
            var n = "" as object;


data = site==null?n :s

The above site is a list collection, which perfectly solves the common problems encountered by ternary operators




Previous:Because there is no implicit conversion between <null> and System.DateTime
Next:Jquery formats /Date(1356969600000)/ into the time format of the year, month, day
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com