How can I check if an object is of a certain type at runtime in C#? -
How can I check that there is a certain type of type on the runtime in an object C #?
You can use the keyword . For example:
using the system; Class CAPP {public static zero major () {string s = "fred"; Tall I = 10; Console.light line ("{0} is {1} an integer", s, (IsInteger (s)? "": "No")); Console.light line ("{0} {1} is an integer", I, (the director)? "": "No")); } Stable Boole Escessor (object obj) {if (obj int is? Obj is long) true back; Second false return; }}
produces output:
Fred is not an integer 10 integer
Comments
Post a Comment