properties

Can I create an automatic property (no private member) with get and set code?

In c#, I can do this: public int Foo { get; set; } Which is nice. But as soon as I want to do anything in the getter or setter, I have to change it to this: private int foo; public int Foo { get { return foo; } set { foo = value; DoSomething(); // all that other code, just to add this line! } } Is it po...

Modifying vertex properties in a Boost::Graph

I am trying to figure out how to use boost::graph to store some information. However, there is information I want tied to each vertex. Staring at the documentation for the library reveals either(a)badly written documentation, or (b), I'm obviously not as good at C++ as I thought. Pick two. I am looking for either a tutorial on assigning...

Joomla: Parameters of List Section Layout are not inherited

Hi, I am Joomla I have a menu item that lists categories in a section. I have changed some of the parameters (like 'do not display headers'). It works on the initial category listing, however after navigating into categories from that page, these parameters no longer apply. For example, lets say we have a menu item 'News' with some pr...

Is it possible to implement properties in languages other than C#?

During a bout of C# and WPF recently, I got to like C#'s properties: public double length_inches { get { return length_metres * 39.0; } set { length_metres = value/39.0; } } Noticing, of course, that length_metres may change from being a field to a property, and the code need not care. WPF can also bind UI elements to object p...

How do I access properties of a javascript object if I don't know the names?

Say you have a javascript object like this: var data = { Name: 'Property Name', Value: '0' }; You can access the properties by the property name: var name = data.Name; var value = data["Value"]; But is it possible to get these values if you don't know the name of the properties? Does the unordered nature of these properties make it...

C# WPF custom control not responding to XAML properties at design-time?

I've created a UserControl which is essentially a button. It's got an Image and a Label on it and I've created two properties to set the Image's source and the Label's text like so: public ImageSource Icon { get { return (ImageSource)this.GetValue(IconProperty); } set { this.SetValue(IconProperty, value); icon.Source = value; ...

How to make a reference type property "readonly"

I have a class Bar with a private field containing the reference type Foo. I would like to expose Foo in a public property, but I do not want the consumers of the property to be able to alter Foo... It should however be alterable internally by Bar, i.e. I can't make the field readonly. So what I would like is: private _Foo; ...

C# Shorthand Property Question

So here is a bit of syntax that I have never seen before, can someone tell me what this means? Not sure if this is supposed to be some shorthand for an abstract property declaration or something or what. public Class1 myVar { get; set; } For what its worth, Class1 is an abstract class. ...

Why should I avoid using Properties in C#?

In his excellent book, CLR Via C#, Jeffrey Richter said that he doesn't like properties, and recommends not to use them. He gave some reason, but I don't really understand. Can anyone explain to me why I should or should not use properties? In C# 3.0, with automatic properties, does this change? As a reference, I added Jeffrey Richter's...

How to expose properties of a WPF DataTemplate?

I have a data template that I use in many pages, the data template contains a few buttons, I want to hide some of these buttons by triggers (I mean setting the IsEnabled Property of these buttons in the page where I use this DataTemplate). In other words, I would even like to set in style triggers/setters a property 'ButtonXIsEnabled', ...

Changing font values from PT to PX in Flash CS4

Just bought Flash CS4 Pro, and for some reason the font sizing is no default Points not Pixels. I can't see anywhere to change this. Anyone got any ideas? Regards ...

How do I reinitialize or reset the properties of a class?

I've created a class with properties that have default values. At some point in the object's lifetime, I'd like to "reset" the object's properties back to what they were when the object was instantiated. For example, let's say this was the class: public class Truck { public string Name = "Super Truck"; public int Tires = 4; pu...

Why will there be no native properties in Java 7?

Is there any rational reason, why native properties will not be part of Java 7? ...

How do you get a Struts2 value from the .properties file programatically?

Say I have a struts.properties file with a defined value uploads.directory . How can I access that value from an Actioncontext programatically? ...

c# - How to iterate through classes fields and set properties

I am not sure if this is possible but I want to iterate through a class and set a field member property without referring to the field object explicitly: public class Employee { public Person _person = new Person(); public void DynamicallySetPersonProperty() { MemberInfo[] members = this.GetType().GetMembers(); foreach (...

Simulate app.config for Java?

I know that you can use java.util.Properties to read Java properties files. See: http://stackoverflow.com/questions/212539/java-equivalent-to-app-config Is there a standard place to put this file? In .NET we put application.exe.config in the same directory as application.exe. The application looks for it here by default. Java can be m...

Java - list of objects to list of single property attributes

I have the ViewValue class defined as follows: class ViewValue { private Long id; private Integer value; private String description; private View view; private Double defaultFeeRate; // getters and setters for all properties } Somewhere in my code i need to convert a list of ViewValue instances to a list containing values of id fiel...

Are get and set functions popular with C++ programmers?

I'm from the world of C# originally, and I'm learning C++. I've been wondering about get and set functions in C++. In C# usage of these are quite popular, and tools like Visual Studio promote usage by making them very easy and quick to implement. However, this doesn't seem to be the case in the C++ world. Here's the C# 2.0 code: public...

Should I use properties in my C# programs or should I use get/set accessors?

I was reading a book called C# Yellow Book by Rob Miles when I came across this statement: Programmer’s love new shiny toys. They are very keen to use language features to show off. Properties can be a bit like this. When considering properties versus get and set methods I am rather a fan of the old fashioned get and set methods beca...

How do I refactor multiple similar methods of this sort into a single method?

Suppose I have a number of related classes that all have a method like this: protected override OnExecute() { this.constructorParm.BoolProperty = !this.constructorParm.BoolProperty; } The type of constructorParm may change (it may also be a static Setting), and the specific property will certainly change, but the type of the prope...