473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

DefaultValueAttribute And Array Properties

How can I set a DefaultValue for an array property? I don't have a project
that uses this anymore, but still am curious. Of all the replies I've
posted here, a simple thing like this is my "gotcha!". :***(

I have a TypeConverter class that inherits from ArrayConverter and it parses
a string into an integer-array. The property that gets/sets the array has
the TypeConverter attribute assigned to this type-converter. One of the
constructor overloads for the DefaultValueAttribute is DefaultValue(Type,
Value) where Type is the type that has a TypeConverter to use to convert
Value to the specified Type.

Well, my TypeConverter isn't the converter for the integer-array type ;( So
I don't believe using that overload is what I need...even though
theoretically, it's the closest thing I've got ...

Thanks,
Mythran
Aug 25 '06 #1
1 1340
Mythran,
I'm not sure if you can use a DefaultValue for an array property. Nor am I
sure if you even should.

Generally what I use is a ShouldSerialize function and a Reset method,
something like:

Public Property Something() As String()
Get
Return ...
End Get
Set(ByVal value As String())
...
End Set
End Property

Public Sub ResetSomething()
...
End Sub

Public Function ShouldSerializeSomething() As Boolean
return ...
End Function

Where ResetSomething will reset the value back to the default for the
Something Property. While ShouldSerializeSomething returns True if the
Something is not at its default value.

I don't have the MSDN link handy that explains the above methods...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Mythran" <ki********@hotmail.comwrote in message
news:ut**************@TK2MSFTNGP04.phx.gbl...
| How can I set a DefaultValue for an array property? I don't have a
project
| that uses this anymore, but still am curious. Of all the replies I've
| posted here, a simple thing like this is my "gotcha!". :***(
|
| I have a TypeConverter class that inherits from ArrayConverter and it
parses
| a string into an integer-array. The property that gets/sets the array has
| the TypeConverter attribute assigned to this type-converter. One of the
| constructor overloads for the DefaultValueAttribute is DefaultValue(Type,
| Value) where Type is the type that has a TypeConverter to use to convert
| Value to the specified Type.
|
| Well, my TypeConverter isn't the converter for the integer-array type
;( So
| I don't believe using that overload is what I need...even though
| theoretically, it's the closest thing I've got ...
|
| Thanks,
| Mythran
|
|
Aug 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gianluca | last post by:
Properties of inherited controls have the default value set to the value that is assigned in the InitializeComponent method in the base form class. Which is correct and useful. In the derived form...
11
by: Laphan | last post by:
Hi All I'm using .getRows() with a local var array instead of doing a recursive loop so that I'm being a good ASP newvbie and closing my object i/o's (the recordset in this case) as quick as...
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
0
by: vthakur | last post by:
Hello: I have generated a c# proxy (client) from the WSDL. One of the class has a defaultValueAtribute. Like so: public class PersonInformationLoadRequest { public string DataSource;
2
by: Mike in Paradise | last post by:
Can you use the DefaultValueAttribute on Decimal PropertyFields? If so what is format for setting the Default value. Thanks... Example /// <summary> /// Field: increment value ///...
1
by: Mythran | last post by:
How can I set a DefaultValue for an array property? I don't have a project that uses this anymore, but still am curious. Of all the replies I've posted here, a simple thing like this is my...
2
by: --== Alain ==-- | last post by:
Hi, I would like to define the default value of my property. My property is from type Bitmap^, therefore i was thinking to do : but i does not work. how is it possible to define this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.