Questions tagged [public-fields]
15 questions
39
votes
5 answers
Why are public fields faster than properties?
I was poking around in XNA and saw that the Vector3 class in it was using public fields instead of properties. I tried a quick benchmark and found that, for a struct the difference is quite dramatic (adding two Vectors together a 100 million times…

JulianR
- 16,213
- 5
- 55
- 85
28
votes
10 answers
a way in c++ to hide a specific function
i have an inheritance struct A : public B, i want to hide individual functions from B, is this possible?
i know the opposite is possible using using BMethod in the A declaration.
cheers

lurscher
- 25,930
- 29
- 122
- 185
15
votes
3 answers
Why can't we use public fields for data binding in C#?
I am aware of the advantages of using properties over fields, like being able to provide additional logic when required in the future.
But I really wonder why it's not possible to use public fields for data binding or even for JSON serializers like…

sapito
- 1,472
- 3
- 17
- 26
14
votes
3 answers
How to access @public instance variable from another class in Objective-C?
I know it's possible to define public instance variable with @public keyword.
However, Objective-C syntax does not allow accessing other class' variable.
What features should I expected from @public Ivar? Or how do I access other class' Ivars?

eonil
- 83,476
- 81
- 317
- 516
9
votes
3 answers
Java secondary not public Class usage produces error "Type is not Visible" even if accessed methods are public in Main class
I have a Main.java file:
public class Main{
private EntityDrawer entityDrawer;
public void setEntityDrawer(EntityDrawer entityDrawer) {
this.entityDrawer = entityDrawer;
}
public EntityDrawer getEntityDrawer() {
return…

will824
- 2,203
- 4
- 27
- 29
5
votes
3 answers
Tools for refactoring C# public fields into properties
I have a lot of C# code that uses public fields, and I would like to convert them to properties.
I have Resharper, and it will do them one by one, but this will take forever.
Does anyone know of an automated refactoring tool that can help with this?

TWA
- 12,756
- 13
- 56
- 92
4
votes
4 answers
Public boost::signal object
I make my boost::signals public because I'm lazy.
class Button {
public:
signal clicked;
};
int main() {
Button btn;
btn.clicked.connect(handleClick);
}
... rather than encapsulating with a…
Iraimbilanja
3
votes
2 answers
Acceptability of public fields in JavaScript
I'm just wondering if public fields (i.e. those not scoped inside the constructor's closure) are acceptable in JavaScript. While the usual mantra is "don't use public fields, use accessors or properties", I noticed that properties are not yet…
user193476
3
votes
2 answers
Dynamic Data with Entity Framework... using [ScaffoldColumn(true)] to show a public property via metadata
... it just doesn't work, at all. I've tried for days, with all different combinations of frick'n stuff and it won't budge.
There are certainly people out there who seem to be blogging about breezing through this sort of thing without seeing a…

Bernard
- 652
- 3
- 7
- 16
2
votes
1 answer
Why do extended classes uses prototypes for methods but not for fields?
Looking at this simple code :
class Animal {
someField = 42;
animalFunc() {
console.log('animal')
}
}
class Lion extends Animal {
lionFunc() {
console.loge('lion')
}
}
let lion = new…

Royi Namir
- 144,742
- 138
- 468
- 792
1
vote
6 answers
In what cases should public fields be used instead of properties?
Possible Duplicate:
Public Data members vs Getters, Setters
In what cases should public fields be used, instead of properties or getter and setter methods (where there is no support for properties)? Where exactly is their use recommended, and…

luvieere
- 37,065
- 18
- 127
- 179
1
vote
1 answer
Reading PGP key information
can someone show a description of the information of what a pgp looks like if only the descriptions were there but not the actual information? something like (i dont remember if the values are correct):
packet-type[4 bits],
total length in…

calccrypto
- 81
- 6
0
votes
2 answers
Should I use public static fields for images and colors?
I have a public static method that returns a color replaced image (I pass in a black image, and it returns the same image with red instead of black, or whatever color I choose).
It looks like this:
public class ColorImage
{
public static UIImage…

aufty
- 407
- 2
- 9
- 26
-1
votes
1 answer
What is the purpose of the => operator on public fields?
What is the purpose of using the => operator with public fields in a C# class? I saw this being done in the unit test code in the eShopOnWeb ASP.NET Core project hosted on GitHub. Is it actually a property with the => operator referring to the value…

Raj Narayanan
- 2,443
- 4
- 24
- 43
-1
votes
2 answers
Is there a free pgp key dumping program?
is there any pgp key dumping program like http://www.pgpdump.net/ that also shows the MPI values as well as the other information? the linked website's program will print out ... for the long MPI, which is perfectly logical, but I want to see the…

calccrypto
- 8,583
- 21
- 68
- 99