Example:
Example:
The cast operator attempts to cast an object to a specific type, and throws an exception if it fails.
Example:
if (someObject is StringBuilder) ...The as operator attempts to cast an object to a specific type, and returns null if it fails.
Example:
StringBuilder b = someObject as StringBuilder;Also related
if (b != null) ...
The cast operator attempts to cast an object to a specific type, and throws an exception if it fails.
Example:
StringBuilder b = (StringBuilder)someObject.
Join the conversation! Your thoughts help the community grow.