473,405 Members | 2,334 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,405 software developers and data experts.

In service, use string to refer to array I should use?

Hi,

I have a service which does posting of messages dependent on CSV
input. Dependent on what the first line of the CSV is different fields
must be extracted and placed into a message. I would like to do it in
the following manner:

x = string value of csv field.

get array name = value of x

so if x = "Y"

then I can do Y[1] and so forth. I would like to avoid having this
using a bunch of logic to return the arrays, is there anything in .Net
or Csharp that allows this kind of thing? Is reflection the answer?
and if so can someone point me to some relevant examples?
Thanks.

Sep 25 '07 #1
2 1227
You could use a Dictionary like so:

....
string x = "Y";
Dictionary<string, string[]dict = new Dictionary<string,
string[]>();
dict.Add(x, new string[]{x});
Console.WriteLine("value of {0} is {1}", "Y", dict["Y"][0]);
....

==================
Regards,
Steve
www.foxville.ch

On Sep 25, 6:13 am, pantagruel <rasmussen.br...@gmail.comwrote:
Hi,

I have a service which does posting of messages dependent on CSV
input. Dependent on what the first line of the CSV is different fields
must be extracted and placed into a message. I would like to do it in
the following manner:

x = string value of csv field.

get array name = value of x

so if x = "Y"

then I can do Y[1] and so forth. I would like to avoid having this
using a bunch of logic to return the arrays, is there anything in .Net
or Csharp that allows this kind of thing? Is reflection the answer?
and if so can someone point me to some relevant examples?
Thanks.

Sep 25 '07 #2
pantagruel,
If you want to work with your CSV format data in arrays, you are going to
need to parse the data and populate the arrays with the values. There is a
recent post in this forum where a reader recommended a good CSV parsing class
that can be found on the codeproject.com site.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"pantagruel" wrote:
Hi,

I have a service which does posting of messages dependent on CSV
input. Dependent on what the first line of the CSV is different fields
must be extracted and placed into a message. I would like to do it in
the following manner:

x = string value of csv field.

get array name = value of x

so if x = "Y"

then I can do Y[1] and so forth. I would like to avoid having this
using a bunch of logic to return the arrays, is there anything in .Net
or Csharp that allows this kind of thing? Is reflection the answer?
and if so can someone point me to some relevant examples?
Thanks.

Sep 25 '07 #3

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

Similar topics

0
by: Ken Dopierala Jr. | last post by:
Hi, I know this post will be considered off-topic. There are a lot of good coders in these groups and I'm hoping someone can help me out. This is what I'm working on. I used to use the...
16
by: Jm | last post by:
Hi All Is it possible to determine who is logged onto a machine from inside a service using code in vb.net ? I have found some code that seems to work under vb6, but doesnt under .NET ? Any help...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
5
by: Ian Meakin | last post by:
I am trying to consume a web service i have written. The web service returns to the client an array of objects. The web service when tested via inetrnet explorer retruns the correct xml data. I...
1
by: Matthew | last post by:
Using .NET 1.1 I trying to consume a web service that returns an integer and an array of type string which I declare and use line this Dim Results() As String Me.txtMain.Text =...
4
by: Jason Richmeier | last post by:
I am sure this has been asked at least once before but I could not find anything when searching. If I set the value of the ExitCode property to 1066 for a windows service, the text "A service...
3
by: Jeremy Chapman | last post by:
I've writtin a very simple web service in axis which returns an array of classes. I consume it in a .net app. When receiving the response, my .net app generates an error "Cannot assign object...
5
by: TompIfe | last post by:
Hi, I have a web service that reads data from an Access database using datareader and place the data in an array that the web method returns. Now, I want to make the web service also to return an...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.