Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Comparison of C Sharp and Java
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Late-bound (dynamic) type === C# features a [[Name binding|late bound]] dynamic type that supports no-reflection dynamic invocation, interoperability with dynamic languages, and ad-hoc binding to (for example) document object models. The {{mono|dynamic}} type resolves member access dynamically at runtime as opposed to statically/virtual at compile time. The member lookup mechanism is extensible with traditional [[Reflective programming|reflection]] as a fall-back mechanism. There are several use cases for the {{mono|dynamic}} type in C#: * Less verbose use of reflection: By casting an instance to the {{mono|dynamic}} type, members such as properties, methods, events etc. can be directly invoked on the instance without using the reflection API directly. * Interoperability with dynamic languages: The dynamic type comes with a [[hub-and-spoke]] support for implementing dynamically typed objects and common runtime infrastructure for efficient member lookup. * Creating dynamic abstractions on the fly: For instance, a dynamic object could provide simpler access to document object models such as [[XML]] or [[XHTML]] documents. Java does not support a late-bound type. The use cases for C# dynamic type have different corresponding constructs in Java: * For dynamic late-bound ''by-name'' invocation of preexisting types, reflection should be used. * For interoperability with dynamic languages, some form of interoperability API specific to that language must be used. The [[Java virtual machine]] platform does have multiple dynamic languages implemented on it, but there is no common standard for how to pass objects between languages. Usually this involves some form of reflection or reflection-like API. As an example of how to use JavaFX objects from Java.<ref>[http://blogs.sun.com/javafx/entry/how_to_use_javafx_in How to Use JavaFX in Your Swing Application] {{webarchive|url=https://web.archive.org/web/20090304204652/http://blogs.sun.com/javafx/entry/how_to_use_javafx_in|date=4 March 2009}}</ref> * For creating and interacting with objects entirely at runtime, e.g., interaction with a document object model abstraction, a specific abstraction API must be used. See also example [[#Interoperability with dynamic languages]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)