473,421 Members | 1,534 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,421 software developers and data experts.

String variable gets value of "System.String[]"

Hi,

I have a Sorted List that has 9 key/value pairs. I am trying to take one of
the key/value pairs and store the value of that key into a string variable.
However, the value that actually gets inserted into the variable is "System.
String[]" and I don't understand what happened to my original value in the
key/value pair.

Thanks for your help,

Andy

snippet:

a key="strAmount"
its value="10.01"
stored in a Sorted List

string strAmount = "";

foreach(DictionaryEntry de2 in colVariableName)
{
if(de2.Key.ToString() == "strAmount")
{
strAmount = de2.Value.ToString();
if(strAmount == "")
{
strAmount = "0.00";
}
if(strAmount == "System.String[]");
{
strAmount = "0.00";
}
}
}
--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
3 1816
>a key="strAmount"
its value="10.01"
stored in a Sorted List
Can you show the insertion code? It seems the value gets stored as a
string array.

strAmount = de2.Value.ToString();


If you do

strAmount = (string)de2.Value;

here instead, and it fails at runtime, you have a definite indication
that the value isn't a string.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
Here is the insertion code:

for(m=0;m<formkeys.Length;m++)
{
colKeysValues.Add(formkeys[m],Request.Form.GetValues(m));
}
colKeysValues.TrimToSize();

Mattias Sjögren wrote:
a key="strAmount"
its value="10.01"
stored in a Sorted List


Can you show the insertion code? It seems the value gets stored as a
string array.
strAmount = de2.Value.ToString();


If you do

strAmount = (string)de2.Value;

here instead, and it fails at runtime, you have a definite indication
that the value isn't a string.

Mattias

--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #3
"Andy Sutorius via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:50***********@DotNetMonster.com...
Here is the insertion code:

for(m=0;m<formkeys.Length;m++)
{
colKeysValues.Add(formkeys[m],Request.Form.GetValues(m));


Note the plurality: GetValues - that returns an array.

Try maybe just using the indexer:
colKeysValues.Add(formkeys[m],Request.Form[m]);

----
Adam Clauss
Nov 17 '05 #4

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

Similar topics

4
by: Jacco | last post by:
Hi, can anyone help me with the following: Suppose I have a variable ll_temp containing pi and a variable test containing "ll_temp". Then with what syntax do I get the value of pi out of test...
7
by: ma740988 | last post by:
The string object value_f doesn't produce the right output. At issue, - I suspect - is the conversion from string to int with istringstream. An alternate approach? Thanks in advance #include...
8
by: Peter Merwood | last post by:
I'm using some sample code from MSDN. The code includes the following statement: Dim content as = .Empty I'm not familiar with the use of the square brackets. Can someone please explain to...
6
by: Michael | last post by:
How can I get X (or another value) from this string "asdfsadfX", basically i want to get what ever is in between the tags and place them in a variable called $www , can anyone help?
2
by: zafzal | last post by:
Hello all, I have a textbox in my asp.net (vb.net) aplicattion, I need to assign it's value to a Variable of type DATE, but it's not a required field, so sometimes I want to send a blank...
9
by: Fei Liu | last post by:
In Accellerated C++, the author recommends that in a header file one should not declare using std::string, using std::vector etc instead one should directly specify the namespace specifier in...
3
by: Sugandh Jain | last post by:
Hi, I am using property like this.. private DateTime? _propName; public DateTime? PropName { get { return _propName; }
6
by: Don Lancaster | last post by:
I need to progrmatically do this inside a loop this.fh03.value = fixFloat (Harms, numPoints) ; with the numbers changing per an index. If I try curHvals = "03" ; // (derived from...
21
by: Sami | last post by:
string = "" or string = string.Empty? should is the proper way? Sami
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.