[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

c#, array issue

Posted on 2013-10-29
9
Medium Priority
?
187 Views
Last Modified: 2013-11-09
I have the following url like

default.aspx?location=["john","smiths","'Los Angeles'","'CA'"],["john","chan","'Fremont'","'CA'"],

and the location parameter may be more or less meaning that it may have more
["xxx","xxx","'xxx'","'xx'"]

In this case of array. How to codes in c#/asp.net to get the value of each one? like the value john, smiths.

Thanks,
0
Comment
Question by:solution1368
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 39610806
Hi

Use Split function to split the string , pls refer
http://www.dotnetperls.com/split

Raj
0
 

Author Comment

by:solution1368
ID: 39613168
I need working codes to my example. Not just a refer url.  thanks
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 39615998
Hi

Posting below the code that I have tested in a console application.

 static void Main(string[] args)
        {

            string inputString = "[john,smiths,'Los Angeles',CA]";
            inputString = inputString.Replace("[", "").Replace("]","").Replace("'","").Replace("\"","");;

            string[] result;
            char[] commaSeparator = new char[] { ',' };

            result = inputString.Split(commaSeparator, StringSplitOptions.None);
            foreach (string str in result)
            {
                Console.WriteLine(str);
            }

            Console.ReadKey();

        } 

Open in new window


Screenshot of Console app with code and output
Regards
Raj
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 39620767
Hi - any update on this ?

Raj
0
 

Author Comment

by:solution1368
ID: 39622423
location=["john","smiths","'Los Angeles'","'CA'"],["john","chan","'Fremont'","'CA'"],

use above data sample. I don't think your codes are working.
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 2000 total points
ID: 39626623
For the data, location=["john","smiths","'Los Angeles'","'CA'"],["john","chan","'Fremont'","'CA'"],
is the output expecting as below ?
john
smiths
Los Angeles
CA
john
chan
Fremont
CA

If not pls post your expected output

Raj
0
 

Author Comment

by:solution1368
ID: 39628727
working. but I think I should explain more because something still do not work.
for each [ ] that listing name and address. I just hope to happen like array

so it will be like below

<div>
Name
City, State
</div>
<div>
Name
City, State
</div>
0
 

Author Closing Comment

by:solution1368
ID: 39634281
Your codes are working. I just need more helps later ... Thanks
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 39635605
you are welcome
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question