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...
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?
...
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...
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?
...
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...
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 ...
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...
These seem to mean the same thing. But what term is more appropriate in what context?
...
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?
...
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...
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#?
...
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" />
...
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...
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...
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...
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...
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?
...
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...
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...
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...