Questions tagged [properties]

A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method. Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls.

Property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method.

Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls. The field-like syntax is said to be easier to read and write than lots of method calls, yet the interposition of method calls allows for data validation, active updating (as of GUI visuals), or read-only 'fields'. That is, properties are intermediate between member code (methods) and member data (instance variables) of the class, and properties provide a higher level of encapsulation than public fields.

See:

18121 questions
7
votes
3 answers

Android TextView enable LinkiFy and Href tags

I want to set a text to the textview which contains href tags as well as normal http links. For ex, text like this "please click here. or visit http://yahoo.com". The issue is I am unable to set both…
Senthil
  • 513
  • 2
  • 13
  • 24
7
votes
4 answers

c# property get,set with different types

I have such an enum and a property. public enum Type { Hourly = 1, Salary = 2, None = 3 }; public string EmployeeType { get { …
Timuçin
  • 4,653
  • 3
  • 25
  • 34
7
votes
3 answers

Set multibinding for a xaml element in code behind

I have the following working XAML code that basically binds a couple of properties to calculate the final position of my user control:
pixtur
  • 1,173
  • 2
  • 12
  • 18
7
votes
3 answers

TypeError: 'str' object is not callable using Selenium through Python

When I try to do code shown below I get error : TypeError: 'str' object is not callable email2_elem = driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[1]/div[1]/div[1]/form[1]/div[1]/input[1]").text()
szymond45
  • 87
  • 1
  • 1
  • 8
7
votes
4 answers

Get/Set as different types

I'd like to define a variable that will accept a string in the SET, but will then convert it to an Int32 and use that during the GET. Here the code that I currently have: private Int32 _currentPage; public String currentPage { get { return…
Damiro
  • 251
  • 4
  • 5
  • 14
7
votes
1 answer

Accessing properties of javascript objects using type dynamic in C# 4

I define a com object as a dynamic type in c# I am able to call methods quite easily. However when I try to access a property on the same object I get an invalid cast exception. The object in question is an array, passed to managed code from…
Fraser
  • 15,275
  • 8
  • 53
  • 104
7
votes
1 answer

Cannot assign to property: 'self' is immutable swift error

Inside my app I created a Protocol called "Positions" and extended the UIView class to conform to this protocol in order to add some properties to the UIView class. I used the code below. import Foundation import UIKit protocol Positions { var…
Lorenzo Santini
  • 655
  • 7
  • 13
7
votes
1 answer

How and when are python @properties evaluated

Here's a snippet of code. class TestClass: def __init__(self): self.a = "a" print("calling init") @property def b(self): b = "b" print("in property") return b test_obj = TestClass() print("a = {}…
Dhiwakar Ravikumar
  • 1,983
  • 2
  • 21
  • 36
7
votes
3 answers

How to use properties in Objective-C?

When should I use the nonatomic, retain, readonly and readwrite properties in Objective-C? For example: @property(nonatomic, retain) NSObject *myObject; If I use nonatomic and retain, does this mean that the object will be retained?
kiran kumar
  • 1,349
  • 4
  • 21
  • 40
7
votes
2 answers

Why does setting the property in the constructor of a struct not work?

I have following code which is not allowed (error below), why? struct A { private int b; public A(int x) { B = x; } public int B { get { return b; } set {…
Mocco
  • 1,183
  • 2
  • 12
  • 25
7
votes
1 answer

Turning off shadow property generation

I'm having a weird issue with setting Entity Framework Core foreign keys. EF keeps adding a shadow property automatically for my property and is creating a foreign key of it. That would be perfectly fine for me, however - I want to be able to set…
Lucas
  • 3,517
  • 13
  • 46
  • 75
7
votes
1 answer

Spring boot: accessing command line args from a bean

I run spring boot application with a single argument - filename. The file contains some properties I need in runtime. When the application starts it checks if args.length==1 But I need this file (properties) in a single point - @Component annotated…
Buch
  • 97
  • 1
  • 10
7
votes
2 answers

Setting ivy home directory in Ant

I would like to set the ivy.default.ivy.user.dir to something other than the default ${user.home}/.ivy2. I can do this on the command line with ant -Divy.default.ivy.user.dir=${WORKSPACE}/IVYCACHE. But, I would like to have it set without a…
user561638
  • 1,299
  • 3
  • 15
  • 26
7
votes
4 answers

Get and set (private) property in PHP as in C# without using getter setter magic method overloading

Summary Code sample: Class People { // private property. private $name; // other methods not shown for simplicity. } Straight forward. Let me assume that $name is a PRIVATE class member (or property, variable, field, call it as you…
O.O
  • 7,179
  • 1
  • 34
  • 32
7
votes
2 answers

How do you create a javascript class with immutable properties

This question is specifically about preventing unwanted properties from being added to a javascript "class". I have a class called Animal. function Animal(){ this.name=""; this.type=""; //20 other properties } What would be the easiest way for a…
techdog
  • 1,451
  • 3
  • 19
  • 38
1 2 3
99
100