c# - Casting to different types with the conditional operator -


i trying check whether object info either word.selection or word.document , use later in program.

here getting trouble.

 object info;  var doc = info word.document ? info word.document : info word.selection;  //do doc.words; 

it returns error:

type of conditional expression cannot determined because there no implicit conversion between 'microsoft.office.interop.word.document' , 'microsoft.office.interop.word.selection'

i can't seem around error

when use ?: operator 2 results must of same type.

use standard if case:

if(info word.document) {     //your code } else { } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -