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

Array question

Okay I am hoping you all can point me in the correct direction. I am new to the whole C#, .NET stuff but here we go. I have an app that gets a listing of files, and then uses a streamreader to find a specific line in the file and adds this along with the UNC to the filename to an arraylist.

My problem is this:

I get it to display the information in the format of:

fieldA-fieldB,\\servershare\filename

The problem I am trying to resolve is that there can be duplicates in this list for FieldA and B. I need to find all the files that have the same fieldA and B in the list and display them. The differing filenames is what is holding me up I believe.

Has anyone run across anything that might help me out? Google is your friend, but you have to know what to google first ;)

Any help would be GREATLY appreciated!
Aug 1 '08 #1
3 1027
Curtis Rutland
3,256 Expert 2GB
Well, if I understand your question correctly, you have strings in this format:
fieldA-fieldB,\\servershare\filename
and you need to find all that have a common fieldA-fieldB?

Well, if fieldA and fieldB don't have commas in them, you could split the string around a comma, and then compare the first part of the results.

Expand|Select|Wrap|Line Numbers
  1. char[] delims = { ',' };
  2. string[] tokens = stringToSplit.Split(delims);
  3. //now tokens[0] should have fieldA-fieldB
  4.  
So you could add tokens[0] to an array or list and then work your logic to find dups.
Aug 1 '08 #2
Well, if I understand your question correctly, you have strings in this format:
fieldA-fieldB,\\servershare\filename
and you need to find all that have a common fieldA-fieldB?

Well, if fieldA and fieldB don't have commas in them, you could split the string around a comma, and then compare the first part of the results.

Expand|Select|Wrap|Line Numbers
  1. char[] delims = { ',' };
  2. string[] tokens = stringToSplit.Split(delims);
  3. //now tokens[0] should have fieldA-fieldB
  4.  
So you could add tokens[0] to an array or list and then work your logic to find dups.
Yes I am doing something like this:
Expand|Select|Wrap|Line Numbers
  1. string[] llarray = line.Split(',');
  2.                             string labelInfo = llarray[1].ToString() + "-" + llarray[2].ToString();
What is happening is that file A will come along and will look in the empty arraylist and realize it is not in there and add it(which it should do). File B will then come along and see file A and see that it is a duplicate and throw it into Arraylist2.
That part of the logic is working, but where I run into problems is that they want to know which file that FileB is conflicting with.

I think the solution is close, I am obviously just not grasping what I need to do to get the corresponding file in Arraylist1 that is causing the duplicates.

I am sure this is very confusing as I am most likely not saying stuff correctly.

Thanks!
Aug 1 '08 #3
Curtis Rutland
3,256 Expert 2GB
I see. You want to track what filenames that have duplicate fields.

Well, if I were in your shoes, I'd make my own class. Really simple, just three public strings: fieldA, fieldB, and filename. Then, when I parse my string, I'd create a new instance of this class. Then do your comparisons using the class, and add it to the dup/non-dup lists, and you will have all the information tied together.

Hope that helps.
Aug 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: SilverWolf | last post by:
I need some help with sorting and shuffling array of strings. I can't seem to get qsort working, and I don't even know how to start to shuffle the array. Here is what I have for now: #include...
9
by: buda | last post by:
Hi, I've been wondering for a while now (and always forgot to ask :) what is the exact quote from the Standard that forbids the use of (&array) (when x >= number_of_columns) as stated in the FAQ...
3
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array...
11
by: Geoff Cox | last post by:
Hello, I am trying to get a grip on where to place the initialization of two arrays in the code below which was created using Visual C++ 2005 Express Beta 2... private: static array<String^>^...
28
by: anonymous | last post by:
I have couple of questions related to array addresses. As they belong to the same block, I am putting them here in one single post. I hope nobody minds: char array; int address; Questions...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
51
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc...
7
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are...
8
by: T. Wintershoven | last post by:
Hello all, I have a form with some checkboxes. The names of these checkboxes come from an array. When i click the submit button the resultcode doesn't recognize the names when i want to check...
4
by: mab464 | last post by:
I have this code on my WAMP server running on my XP machine if ( isset( $_POST ) ) { for($i=0; $i<count($_POST);$i++) { if ($ans != NULL ) $ans .= ", " . $_POST ; // Not the first...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.