From: Leon_Amirreza on 29 Dec 2009 14:24 hi How can I have this in c# (or any equivalent code that does the same thing): [DefaultValue(Environment.NewLine)] or [DefaultValue(f())] f() is a function that returns a value.
From: Jesse Houwing on 29 Dec 2009 14:46 * Leon_Amirreza wrote, On 29-12-2009 20:24: > hi > How can I have this in c# (or any equivalent code that does the same > thing): > > [DefaultValue(Environment.NewLine)] > > or > > [DefaultValue(f())] > > f() is a function that returns a value. You cannot. -- Jesse Houwing jesse.houwing at sogeti.nl
From: Family Tree Mike on 29 Dec 2009 17:10 On 12/29/2009 2:24 PM, Leon_Amirreza wrote: > hi > How can I have this in c# (or any equivalent code that does the same > thing): > > [DefaultValue(Environment.NewLine)] > > or > > [DefaultValue(f())] > > f() is a function that returns a value. You can set those values for the properties in the constructor. -- Mike
From: Mick Doherty on 31 Dec 2009 06:05 The DefaultValueAttribute basically just determines a value which does not need to be serialized and which will be set upon a reset command. It does not set the initial value, this needs to be done by yourself. To do this with a non fixed value you should define ShouldSerialize* and Reset* methods instead, where * is the property name. i.e. -- 8< -------------------------------------------------- private string someProperty = Environment.NewLine; public string SomeProperty { get{ return someProperty; } set{ someProperty = value; } } private bool ShouldSerializeSomeProperty() { return !SomeProperty.Equals(Environment.NewLine); } private void ResetSomeProperty() { SomeProperty = Environment.NewLine; } -- 8< -------------------------------------------------- -- Mick Doherty http://dotnetrix.co.uk/nothing.htm "Leon_Amirreza" <r_rahmaty(a)hotmail.com> wrote in message news:24DA2D74-4053-4774-B7A0-55BE7F737E08(a)microsoft.com... > hi > How can I have this in c# (or any equivalent code that does the same > thing): > > [DefaultValue(Environment.NewLine)] > > or > > [DefaultValue(f())] > > f() is a function that returns a value.
|
Pages: 1 Prev: Economical Auction Site Next: Looking for SMS, email, fax Notification library |