473,749 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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(Diction aryEntry de2 in colVariableName )
{
if(de2.Key.ToSt ring() == "strAmount" )
{
strAmount = de2.Value.ToStr ing();
if(strAmount == "")
{
strAmount = "0.00";
}
if(strAmount == "System.Str ing[]");
{
strAmount = "0.00";
}
}
}
--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
3 1837
>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.ToStr ing();


If you do

strAmount = (string)de2.Val ue;

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<formk eys.Length;m++)
{
colKeysValues.A dd(formkeys[m],Request.Form.G etValues(m));
}
colKeysValues.T rimToSize();

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.ToStr ing();


If you do

strAmount = (string)de2.Val ue;

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.c om" <fo***@DotNetMo nster.com> wrote in
message news:50******** ***@DotNetMonst er.com...
Here is the insertion code:

for(m=0;m<formk eys.Length;m++)
{
colKeysValues.A dd(formkeys[m],Request.Form.G etValues(m));


Note the plurality: GetValues - that returns an array.

Try maybe just using the indexer:
colKeysValues.A dd(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
3257
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 ?? ll_temp = 3.1415926 test= "ll_temp"
7
3676
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 <iostream> #include <sstream> #include <string> using namespace std;
8
4860
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 me what the difference between "Dim content as " and "Dim content as String". Thanks. Peter,
6
1661
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
2136
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 field. I declared a variable as a date datatype and when it´s going to receive the content of the text field, it shows the following error "Cast from
9
3783
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 code. for example, this is bad practice: header.h #include <string> using std::string;
3
12016
by: Sugandh Jain | last post by:
Hi, I am using property like this.. private DateTime? _propName; public DateTime? PropName { get { return _propName; }
6
4111
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 index to provide leading zero)
21
2974
by: Sami | last post by:
string = "" or string = string.Empty? should is the proper way? Sami
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.