Menu

keywords-byvalue

Will Pittenger

The byvalue keyword is a type modifier that forces a class instance to by stored or passed by reference. byvalue can't be part of a type alias. It can only be used when declaring a var declaration. If that instance is then passed or assigned to a reference variable, the reference will point to the byvalue location. You will only duplicate the instance if the new location is also byvalue. Only classes that implement the IClonable interface can by byvalue. That interface is used to copy a reference to a byvalue location or to copy one byvalue location into another. byvalue can't be combined with the ref or out keywords.

\var\ \byvalue\ /identifier/ [= DefaultValue]

/DefaultValue/, if present, must be a valid constant of the desired type, a call to the type's constructor using the new keyword, or something that can be converted to the desired type.


Related

Wiki: Appendices-Terms-Type descriptors
Wiki: By value versus by reference
Wiki: Keywords
Wiki: keywords-null
Wiki: keywords-out
Wiki: keywords-ref
Wiki: keywords-returns
Wiki: keywords-var
Wiki: operators-brackets