properties

C#3.0 Automatic properties, why not access the field directly?

With the new approach of having the get/set within the attribut of the class like that : public string FirstName { get; set; } Why simply not simply put the attribute FirstName public without accessor? ...

.NET - Find all references of property assignment

Hello, I am using VB.NET. In Visual Studio, if I right-click a property name and click "Find All References", it searches for all instances of the property being used. However, a property is always used either for assignment (Set method) or retrieval (Get method). Is there any way of searching for only one of these uses? e.g. search fo...

How do I properly store and retrieve internationalized Strings in properties files?

I'm experimenting with internationalization by making a Hello World program that uses properties files + ResourceBundle to get different strings. Specifically, I have a file "messages_en_US.properties" that stores "hello.world=Hello World!", which works fine of course. I then have a file "messages_ja_JP.properties" which I've tried all...

New automatic properties in c# 3.0, what's the benefit?

Hi, Whats the benefit of: public string User {get; set;} over public string User; Since you can't access the private member in the first case, how is it any different that just making your property public? ...

How to set a default value using "short style" properties in VS2008 (Automatic Properties)?

Hi, How can I setup a default value to a property defined as follow: public int MyProperty { get; set; } That is using "prop" [tab][tab] in VS2008 (code snippet). Is it possible without falling back in the "old way"?: private int myProperty = 0; // default value public int MyProperty { get { return myProperty; } set { myPro...

C# property attributes

I have seen the following code: [DefaultValue(100)] [Description("Some descriptive field here")] public int MyProperty{...} The functionality from the above snippit seems clear enough, I have no idea as to how I can use it to do useful things. Im not even sure as to what name to give it! Does anyone know where I can find more informa...

How do properties work in Object Oriented MATLAB?

I am trying to create a MATLAB class with a member variable that's being updated as a result of a method invocation, but when I try to change the property within the class it (apperently, from what I understood from MATLAB's memory management) creates a copy of the object and then modifies it, leaving the original object's property untou...

Need Help: VS 2005 Properties Changing

I am working in Visual Studio 2005. I have multiple splitters on the screen. I have set the splitters IsFixed and I have also set fixed panel sizes. In addition to this I have locked the control. For some reason, when I switch into debug mode the splitter distance value is changing entirely on its own. These changes do not take place wit...

Are there any other useful attributes for c# properties?

Possible Duplicate: Most Useful Attributes in C# besides: [DefaultValue(100)] [Description("Some descriptive field here")] public int MyProperty{get; set;} What other C# Attributes are useful for Properties, after learning these I feel like I'm Missing out. Related Questions Most Useful Attributes in C# ...

Retrieving Attribute names of an Entity in MS CRM 4.0

I am back again with another question on ms crm. The latest thing i am trying to do is retrieve the attribute name and type that exist in an entity, Dynamic Entity to be precise. I have the following code. DynamicEntity contactEntity = new DynamicEntity(); contactEntity.Name = EntityName.contact.ToString(); Property t = nu...

C# custom event handlers

If I have a property: public list<String> names { get; set; } How can I generate and handle a custom Event for arguments sake called 'onNamesChanged' whenever a name gets added to the list? ...

What is the best way to implement a property that is readonly to the public, but writable to inheritors?

If I have a property that I want to let inheritors write to, but keep readonly externally, what is the preferred way to implement this? I usually go with something like this: private object m_myProp; public object MyProp { get { return m_myProp; } } protected void SetMyProp(object value) { m_myProp = value; } Is there a better...

Sharepoint custom user and document library specific properties

Is there a standard way to assosciate custom properties with a user? In particular I need to store the number of items per page a user selected in a grid of a document library separately for each user and document library. @Edit: sorry about this vagueness, I wanted to do it programmatically. It seems like I've found the solution, it is...

PostSharp aspect for property setters, calling generic method

We have a base object we use for some MVC-like system, where each property in a descendant is written like this: public String FirstName { get { return GetProperty<String>("FirstName", ref _FirstName); } set { SetProperty<String>("FirstName", ref _FirstName, value); } } This is done both for debugging purposes and for notifica...

Should members of an object be automatically set in the class?

When you have a complex property, should you instantiate it or leave it to the user to instantiate it? For example (C#) A) class Xyz{ List<String> Names {get; set;} } When I try to use, I have to set it. ... Xyz xyz = new Xyz(); xyz.Name = new List<String>(); xyz.Name.Add("foo"); ... Where as if I modify the code B) cla...

Correct approach to Properties.

I am working in Java on a fairly large project. My question is about how to best structure the set of Properties for my application. Approach 1: Have some static Properties object that's accessible by every class. (Disadvantages: then, some classes lose their generality should they be taken out of the context of the application; they...

List Object's built-in Properties

Is there a way for me to loop over a Javascript Object's built-in properties? for...in gets me close to where I want to go, but "A for...in loop does not iterate over built-in properties." ...

Detecting changes in property values of a .NET object?

Hi, I have a form which is used to insert/display and update. In the edit mode (update), when I pass my BO back to the Controller, what is the best possible way to check if any of the property values were changed, in order to execute the update to the datastore? textbox1.text = CustomerController.GetCustomerInformation(id).Name A c...

Java resource files

I'm writing a small GUI app that contains some "editor" functionality, and something that I'd like to let users open a few sample text files to test things out quickly. The easiest way of doing this would be to package a separate zip with the appropriate sample files, and have them open them manually; I'd like to make things a little mor...

How to modify properties of a Matlab Object

I 've created a Matlab Class, something like that : classdef myclass properties x_array = []; end methods function increment(obj,value) obj.x_array = [obj.x_array ; value); end end end The problem is, the property "x_array" is never modified when i invoke the increment() function: ex: s = myclass i...