name=(value) @name=value end end Read-only simple public access to implied @name variable class Student attr_reader :name end Read-write simple public access to implied @name variable class Student attr_accessor :name end Rust struct Student { name: String, } impl Student { fn name(&self) -> &String { &self.name } fn set_name(&mut self, name: String) { self.name = name } } Smalltalk age: aNumber " Set the receiver age to be aNumber if is greater than 0 and less than 150 " (aNumber between: 0 and: 150) ifTrue: [ age := aNumber ] Swift class Student { private var _name: String = "" var name: String { get { return self._name } set { self._name = newValue } } } Visual Basic .NET This example illustrates the VB.NET idea of properties, which are used in classes. Similar to C#, there is an explicit use of the Get and Set methods. Public Class Student Private _name As String Public Property Name() Get Return _name End Get Set(ByVal value) _name = value End Set End Property End Class In VB.NET 2010, Auto Implemented properties can be utilized to create a property without having to use the Get and Set syntax. Note that a hidden variable is created by the compiler, called _name, to correspond with the Property name. Using another variable within the class named _name would result in an error. Privileged access to the underlying variable is available from within the class. Public Class Student Public Property name As String End Class See also Property (programming) Indexer (programming) Immutable object References Method (computer programming) Articles with example BASIC code Articles with example C Sharp code Articles with example C++ code Articles with example Java code Articles with example Lisp (programming language) code Articles with example Pascal code Articles with example Perl code Articles with example PHP code Articles with example Python (programming language) code Articles with example Racket code Articles with example Ruby code Articles with example Smalltalk code