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...
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...
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...
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...
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...
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; ...
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;
...
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.
...
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...
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', ...
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
...
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...
Is there any rational reason, why native properties will not be part of Java 7?
...
Say I have a struts.properties file with a defined value uploads.directory . How can I access that value from an Actioncontext programatically?
...
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 (...
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...
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...
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...
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...
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...