property

.NET property generating "must declare a body because it is not marked abstract or extern" compilation error

I have a .NET 3.5 (target framework) web application. I have some code that looks like this: public string LogPath { get; private set; } public string ErrorMsg { get; private set; } It's giving me this compilation error for these lines: "must declare a body because it is not marked abstract or extern." Any ideas? My understanding...

How can I automatically add properties in Objective-C?

When adding new properties to classes, I find myself typing the same things over and over in xcode: add TYPE *NAME; (in .h interface) add @property (nonatomic, retain) TYPE *NAME; (in .h) add @synthesize NAME; (in .m) add [NAME release]; (in .m dealloc) (I'm in a non-garbage collected environment.) How can I do this automatically? ...

How to convert an "object" into a function in JavaScript?

JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"? This works: var foo = function() { return 1; }; foo.baz = "qqqq"; At this point, foo() calls the function, and foo.baz...

Exposing Member Objects As Properties or Methods in .NET

In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method? ...

Using the typical get set properties in C#... with parameters

Hello, I'd like to do the same in C#. Is there anyway of using properties in C# with parameters in the same way I've done with the parameter 'Key' in this VB.NET example? Private Shared m_Dictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object) Public Shared Property DictionaryElement(ByVal Key As String) As...

python properties and inheritance

I have a base class with a property which (the get method) I want to overwrite in the subclass. My first thought was something like: class Foo(object): def _get_age(self): return 11 age = property(_get_age) class Bar(Foo): def _get_age(self): return 44 This does not work (subclass bar.age returns 11). I ...

Extremely Weird Bug with a property in C#

I have a certain application which feeds information into an object, after comparing the new information to the old information. It goes something like set { oldval=_value; _value=value; if (some comparison logic) raiseEvent(); } This all happens on a background thread, in an infinite loop, which intermittently sleeps...

What is the difference between attribute and property?

These seem to mean the same thing. But what term is more appropriate in what context? ...

How do I programatically set the SharePoint's site collections Search Center property?

I have a site collection and I want to set the search center value to be the same as another site collection. The site collection is created in code, so I need to be able to set the property after the site collection has been created. How can I do this programatically? ...

Should you access a variable within the same class via a Property?

If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it. My question is should you also always do so within the class? I've always used the Property if there is one, even within the class, but would like to hear some arguments for and against as to...

Making a generic property

I have a class that stores a serialized value and a type. I want to have a property/method returning the value alredy casted: property string Value { get; set; } property Type TheType { get; set; } property typeof(TheType) CastedValue{ get {return Convert.ChangeType(Value, typeof(_Type)); } Is this posible in C#? ...

WPF: Problem with Checkbox when binding datatrigger to property "Ischecked".

I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below: <Style TargetType="CheckBox"> <Setter Property="IsEnabled" Value="True" /> ...

How do I declaratively insert a property value of a page into it's rendering?

I would like to have an aspx page that contains something like.... <form id="form1" runas=server > Hello <%= Me.UserName() %> </form> and a code-behind something like... Public Class Somepage inherits SomeOtherPage Private Readonly Property UserName() as String Get return "Rory" End Get End Property E...

Dynamically assigning projects property name to variable within a class

Hi There... I have created a class to dynamically put together SQL function statements within a project. I have found this class to be pretty useful and would like to incorporate into future projects namespace connectionClass { public class connClass { NpgsqlConnection conn = new NpgsqlConnection(projectName.Properties...

Overriding fields or properties in subclasses

I have an abstract base class and I want to declare a field or a property that will have a different value in each class that inherits from this parent class. I want to define it in the baseclass so I can reference it in a base class method - for example overriding ToString to say "This object is of type property/field". I have got thr...

What is the best way to access properties from the same class, via accessors or directly?

This is something I'm not much consistent about and always curious about what other people do. How do you access internal properties (private or public)? For example you've got this property : Private _Name As String Public Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Nam...

How to find which webpart has the property pane open for edit in wss 3.0?

I have multiple webparts present on a page. When the web part is modified, it opens a 'Property Pane'. How do I identify which web part open the property pane programmatically? ...

ReadOnly vs Property within Assembly Question/Conundrum

How can I make a Property "ReadOnly" outside the Assembly (DLL) for people using the DLL but still be able to populate that property from within the assembly for them to read? For example, if I have a Transaction object that needs to populate a property in a Document object (which is a child class of the Transaction class) when somethin...

JavaScript - Identify whether a property is defined and set to 'undefined', or undefined

Say I have the following code: function One() {} One.prototype.x = undefined; function Two() {} var o = new One(); var t = new Two(); o.x and t.x will both evaluate to undefined. o.hasOwnProperty('x') and t.hasOwnProperty('x') will both return false; the same goes for propertyIsEnumerable. Two questions: Is there any way to tell t...

How do you configure a get-only property for a Silverlight-enabled WCF service

I'm not certain where the error is resulting (from silverlight, from wcf, something else...) but, I have a WCF service being called from Silverlight. The method returns a class, with a property that does not have a setter. This throws an error. If I add a setter to the property then it does not give an error. The error is the usual impe...