Most voted "property" questions
111 questions
Sort by count of
-
37
votes3
answers8360
viewsProperty x Attribute
One propriedade of a class is not the same thing as a atributo? What’s the real difference between them? Or propriedade is a synonym for atributo or vice versa? Or varies according to the…
oop terminology characteristic-language property attributesasked 9 years, 4 months ago MeuChapeu 5,875 -
30
votes2
answers5203
viewsMethods and properties in C# - advantages and disadvantages
In C# we have properties with getters and setters, which facilitates the insertion and reading of data in an object when some logic should be performed. In other languages, such as Java these tasks…
-
29
votes1
answer1530
viewsProperty Vs variables
I’ve always used properties in C# this way: public int Numero { get; set; } Today I asked myself, why do I use this get and set instead of a variable? Is there a difference? I only use it that way…
-
28
votes6
answers4346
viewsWhat is the difference between attribute and field in the classes?
When I am studying object-oriented programming, at times I hear about fields and attributes of a class, but the two seem to be different definitions to refer to the same thing. What’s the…
-
20
votes3
answers14315
viewsPythonic way of defining setters and getters
Searching the internet, I see that it is highly recommended not to use Setter and Getters in Python classes. However, I cannot determine a way to access private values without using them. There are…
-
16
votes4
answers845
viewsIs it possible to access an object within itself?
Cadastro = { "descricao" : "Novo usuário", "editando" : false } It is possible at runtime I get the value of the property by "editing" and use it? Something like: Cadastro = { "descricao" : "Novo…
-
14
votes2
answers289
viewsNew C# 6 functionality "Auto-Property initializers" is just a facilitator?
One of the new C#6 features is the possibility to initialize properties at the time of declaration. public class Customer { public string First { get; set; } = "Jane"; public string Last { get; set;…
-
12
votes4
answers595
viewsHow to create a variable where to access its properties via string?
I’d like to access by string the properties of an object: (EXAMPLE 1) var cor = casa["cor"]; var tamanho = casa["tamanho"]; Instead of accessing like this: (EXAMPLE 2) var cor = casa.cor; var…
-
12
votes2
answers141
viewsDynamic declaration in attribute property
As part of a microplataforma ORM I’m developing, I’m defining a generic class that implements exclusively tight Coupling (1 record x 1 object). public class Course : MicroEntity<Course> {…
-
11
votes3
answers1611
viewsDynamic property name in Javascript
I have the following code: var nomePropriedade = "Propriedade1"; var meuObjeto = { "nome" : "valor" } I would like the property name of meuObjeto received the variable value nomePropriedade. Thus,…
-
10
votes1
answer333
viewsDelphi estate
I have a component that has the function of connecting to a specific hardware. It connects through the network or serial port. Something like the code below: TConexao = (conRede, conSerial);…
-
9
votes2
answers274
views -
9
votes1
answer209
viewsStrange property initialization
While reading a tutorial on Entity Framework, I came across an example of code where there was a line that, for me, is unknown: Student stud = new Student() { StudentName = "New Student" }; I…
-
9
votes2
answers354
viewsHow do C#properties work?
In Java I usually create private attributes and create methods getters and setters, on account of the encapsulation. I couldn’t quite understand how this works in the C#.…
-
9
votes1
answer126
viewsA property occupies space in the object?
I was reading a question about properties and saw that she is at the same time one or two methods. Do you have any additional cost in memory and processing in using it? If you don’t use the code you…
-
9
votes1
answer420
viewsHow can I "postpone" the startup of a property?
There are situations where the property initialization is not possible to be made in the declaration, its value is only known later. An example of this is, on Android, references to views of a…
-
9
votes3
answers170
viewsHow to change property access level in an inheritance?
I have a class that when inherited I want one of its public attributes to become private, so that the user does not have access to the use of this variable in this class, but I do not know how to do…
-
8
votes6
answers1227
viewsProperty readonly . NET
I received this question in a test and could not answer: "How is it possible to declare a property readonly in . NET / C#?"
-
8
votes3
answers370
viewsPrivate set of property in an interface
I’m modeling a C# interface that has a property. However, I want to ensure that all classes that implement this interface maintain the Setter as private: public interface IBar { string Id { get;…
-
7
votes2
answers4310
viewsHow to prevent a property from being mapped to an entity in the Entity Framework?
I need to enter a property in the model class, but when I enter the code first, it says the table already exists and changes have been made. My code: public class Data { [Key] public int Id { get;…
c# entity-framework asp.net-mvc-4 property code-firstasked 10 years, 8 months ago Luciano Azevedo 402 -
7
votes1
answer492
viewsUnderstanding the pythonic way of dealing with properties
I am on time trying to understand how this issue of python properties works. But the problem is that in all the tutorials net out only find the damn example with only one attribute. I’m looking for…
python python-3.x getters-setters property decorator-patternasked 9 years, 4 months ago Devel Silva 73 -
7
votes2
answers329
viewsHow to transform attributes into properties?
In C#, I can avoid using getter and setter, transforming the attributes into properties, as below: public class Pessoa { public int pes_idade { get; set; } public string pes_nome { get; set; } } You…
-
6
votes1
answer1230
viewsWhen using __constructor magic method or set and get
My doubt is with constructor relation, for example, I have a class with name, age. the correct is to use __construct to pass values to them or use set e get ?
-
6
votes1
answer479
viewsPrivate Property / Protected JS / jQuery
Is it possible to make an object in js/jQuery where it is visible only using the method, for example get / set? An example of an object: if I give a console.log(pessoa.documeto), it will display the…
-
6
votes1
answer83
viewsAccess properties without knowing name
You can access all your settings inside the class (estates) without having their names? For example, if I create an instance of a class $classe = new Classe(), and I’m defining things in her:…
-
6
votes1
answer694
viewsHow to pick up attribute dynamically
How I would make the following PHP code in C#? class teste{ public $x = 10; public $y = 10; } $n = new teste(); $a = "y"; print_r($n->{$a}); Note that dynamism is in the variable $a, in which if…
-
6
votes2
answers174
viewsHow in ASP.NET 5 is this property defined?
In ASP.NET 5 in the method Configure class Startup we can receive in the parameters a reference to an object whose class implements IHostingEnvironment. One of the properties of this class is…
-
6
votes3
answers171
viewsIs it possible to have properties other than those generated automatically in a data class?
Kotlin allows you to simplify the creation of what in Java we call POJO: data class Person(val firstName: String, val lastName: String) With this we get a class with the getter for all variables…
-
6
votes2
answers368
viewsHow to get the properties of a type when using Generics C#
I have the following class: public class Pessoa { public int id { get; set; } public string Nome { get; set; } public DateTime DataNascimento { get; set; } } I’ve developed a method to get her…
-
6
votes1
answer145
viewsWhat are dynamic properties?
I am studying ASP.NET and saw the following code snippet: ViewBag.QtdNovosComunicados = (from c in comunicados where c.DataCadastro > UsuarioLogado.dtUltimoAcesso select c).Count(); I understand…
-
6
votes1
answer138
viewsWhy do auto properties exist in C#?
I have a doubt, because in C# there are auto properties that are usually used like this: public double price {get; private set;} and because she’s a public she can be accessed directly and on top I…
-
6
votes2
answers119
viewsC# properties for those who know Java
What a Java programmer needs to know about basic properties (properties) in order to read code written in C#?
-
5
votes1
answer90
viewsAdd properties to the [Node] element
Is there a problem with adding custom properties directly to the [Node] element? For example: document.getElementById('minhaDiv').minhaPropriedade = 'teste'; I’m using Firefox and I haven’t had…
-
5
votes1
answer67
viewsHow to get the value of a property using variable as name?
How to make him search the property ABC instead of A? Taking this code into account: A = 'ABC'; alert(LANG.A);
-
5
votes1
answer70
viewsProperty access modifier C#
I noticed that it is possible to sign a property access mode as private: public string Codigo { get; private set; } Or just ignore it: public string Codigo { get; } Is there any difference or…
-
5
votes1
answer143
viewsTraits don’t take property superscripts?
According to the excerpt from the PHP Handbook A Trait is intended to reduce some simple inheritance limitations by allowing a developer to reuse sets of methods freely... Take an example: trait…
-
5
votes3
answers119
viewsWhy declare property twice in one class?
When declaring a property in one class, they usually declare twice, one public and the other private. What is the purpose? private int _years; public int Years { get { return _years; } }…
-
5
votes1
answer115
viewsWhat is Lazy instantiation?
I saw here on wakim’s response that code snippet: data class Person(val firstName: String, val lastName: String) { val fullName: String by lazy { "$firstName $lastName" } } What is this so-called…
-
5
votes1
answer183
viewsPass arguments to the property getter
VB.NET allows you to declare parameters in the property getter Public ReadOnly Property Propriedade(param As String) As String Get Return param & "!" End Get End Property It’s a strange feature…
-
5
votes1
answer100
viewsHow to use expanded property in C#
I have a problem, I created a class containing the following property: public class MinhaClasse { public int Idade {get; set;} } But when I do it: public class MinhaClasse { public int Idade { get{…
-
5
votes2
answers237
viewsAccess Javascript properties: point notation or square brackets?
Let’s say we have an object called rectangulo and a property called area. We can access this property in the following ways: Point notation: rectangulo.area. Bracket notation: rectangulo['area']. I…
javascript characteristic-language objects propertyasked 4 years, 4 months ago Tiago Martins Peres 李大仁 236 -
5
votes2
answers279
viewsWhat is this "k_BackingField"
I have a project to create a C# Smart Device for Windows CE. I received a code result reverse engineering, but there is a part that I am not able to understand or adapt. Below follows the code:…
-
4
votes1
answer344
viewsDifferences in constructors using property vs field (field)
namespace WMB.CieloB { internal class FuncoesCielo { internal FuncoesCielo(int iDC, Boleto boleto) { IDCliente = iDC; this.boleto = boleto; } public int IDCliente { get; set; } internal Transaction…
-
4
votes3
answers216
viewsWhy is the behavior of the undefined variable different from the undefined property?
I’ve noticed this for a long time in Javascript. If I write a certain code where the variable is not defined in any scope, an exception is thrown: console.log(preco) Upshot: Uncaught Referenceerror:…
-
4
votes3
answers218
viewsPublic field X property
I have a string defined as "name" initially it is as private. string nome; In case I assign the methods get/set, and to stay in the pattern I change the initial letter to uppercase, getting: string…
-
4
votes3
answers103
viewsNullable property in C#
I was looking at some tutorials and suddenly I saw this property public Nullable<int> Id {get; set;}. What it means and when I would use it?
-
4
votes1
answer127
viewsWhat are Javascript property descriptors and attributes and how do they work?
Eventually I read, mainly in more advanced content about objects in Javascript, the terms "proprietary descriptors" and "property attributes". I believe they are related concepts. What they are and…
-
4
votes2
answers67
viewsIs there practical application in write-only properties?
In object-oriented programming, a property is a member of a class that provides information about the object. That is, properties expose attributes. Properties can also be "write only". An example…
oop characteristic-language software-engineering property language-independentasked 3 years, 5 months ago vinibrsl 19,711 -
3
votes2
answers122
viewsHeirs attributes with prototype do not appear in Javascript Reflection
I have the class Animal that has some properties that are enumerable: true, that is, I can list them via Reflection using for..in. So I have the class Coelho that has the attribute cor. How rabbit…
-
3
votes3
answers271
viewsChange read-only property in class itself
A read-only property implements only the provider get. But what if I want to modify this property in the class itself? Let’s say public class MinhaClasse { public string PropriedadeDeMinhaClasse {…