Questions tagged as 'propriedade'

4
answers

How to create a variable where access its properties via string?

I would like to access by string the properties of an object: (EXAMPLE 1) var cor = casa["cor"]; var tamanho = casa["tamanho"]; Instead of access like this: (EXAMPLE 2) var cor = casa.cor; var tamanho = casa.tamanho; Creating this wa...
asked by 13.10.2015 / 18:42
2
answers

New functionality of C # 6 "Auto-property initializers" is just a facilitator?

One of the new C # 6 is the ability to initialize properties at the time of declaration. public class Customer { public string First { get; set; } = "Jane"; public string Last { get; set; } = "Doe"; } The goal is just to make it e...
asked by 15.01.2016 / 16:14
3
answers

Pythonic 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 can not determine a way to access private values without using them. There are several recommendations on using properties, bu...
asked by 28.02.2017 / 05:32
5
answers

Property readonly .NET

I received this question in a test and could not answer: "How can I declare a readonly property in .NET / C #?"     
asked by 31.01.2014 / 15:36
1
answer

Does a property take up space on the object?

I was reading a query about properties and saw that it is one or two methods at one time. Is there any additional cost in memory and processing in using it? If you do not use the code can you get more optimized?     
asked by 11.05.2017 / 16:11
2
answers

How do properties work in C #?

In Java, I usually create private attributes and create getters and setters methods because of encapsulation. I could not understand right how this works in C# .     
asked by 05.10.2016 / 14:44
1
answer

How can I "delay" the initialization of a property?

There are situations when initializing the property can not be made in the declaration, its value is only known later. An example of this is that in Android, references to views of a layout can only be obtained after the setContentView...
asked by 08.08.2017 / 16:24
3
answers

Why declare properties twice in a class?

When declaring a property in a class, they usually declare twice, one public and the other private. What is the purpose? private int _years; public int Years { get { return _years; } }     
asked by 17.05.2017 / 18:39
1
answer

Access properties without knowing name

Is it possible within the class to access all your (properties) definitions without having their names? For example, if I create an instance of a class $classe = new Classe() , and I'm defining things in it: $classe->ComprarFile...
asked by 13.10.2015 / 03:18
1
answer

How to get attribute dynamically

How would I do 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 the dynamism is in the variable $a , in which if I change to x i...
asked by 23.12.2015 / 01:45