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!
=== User-defined value type (struct) === C# allows the programmer to create user-defined [[value type]]s, using the {{mono|struct}} keyword. Unlike classes and like the standard primitives, such value types are passed and assigned by value rather than by reference. They can also be part of an object (either as a field or [[Boxed type|boxed]]), or stored in an array without the memory indirection that normally exists for class types. Because value types have no notion of a {{mono|null}} value and can be used in arrays without initialization, they always come with an implicit [[default constructor]] that essentially fills the struct memory space with zeroes. The programmer can only define additional constructors with one or more arguments. Value types do not have [[virtual method table]]s, and because of that (and the fixed [[memory footprint]]), they are implicitly sealed. However, value types ''can'' (and frequently do) implement [[Interface (object-oriented programming)|interfaces]]. For example, the built-in integer types implement several [[Interface (object-oriented programming)|interfaces]]. Apart from the built-in primitive types, Java does not include the concept of value types.
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)