c# - can we replace IS operator with some other operators -


can replace is operator functionality other operators or functions or other except as? have tried replace this

class test { program = new program(); programtwo b = new programtwo(); if(a.gettype()?. == b.gettype()) console.writeline("true"); } 

but not working case of derived object checking base class 1 please me how solve this?

i don't understand why don't want use is. wayyyy more beautiful. code clearer if use is.

an alternative isassignablefrom. (docs)

console.writeline(typeof(object).isassignablefrom (5.gettype())); 

a second alternative isinstanceoftype. (docs)

console.writeline(typeof(object).isinstanceoftype(5)); 

the above 2 similar to

console.writeline(5 object); 

see difference between readability?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

python - TypeError('Unrecognized keyword arguments: ' + str(kwargs)) # Validate user data -