Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
QuestionHow i can block the incomming network traffic using C# .NET Pin
Tahir Abbasi22-Apr-08 8:16
Tahir Abbasi22-Apr-08 8:16 
AnswerRepost ignore Pin
led mike22-Apr-08 8:39
led mike22-Apr-08 8:39 
AnswerRe: How i can block the incomming network traffic using C# .NET Pin
Pete O'Hanlon22-Apr-08 8:49
mvePete O'Hanlon22-Apr-08 8:49 
GeneralRe: How i can block the incomming network traffic using C# .NET Pin
Paul Conrad22-Apr-08 15:28
professionalPaul Conrad22-Apr-08 15:28 
Generalproblems splitting string Pin
stephan_00722-Apr-08 7:55
stephan_00722-Apr-08 7:55 
GeneralRe: problems splitting string Pin
led mike22-Apr-08 8:40
led mike22-Apr-08 8:40 
GeneralRe: problems splitting string Pin
Guffa22-Apr-08 8:46
Guffa22-Apr-08 8:46 
GeneralRe: problems splitting string Pin
stephan_00722-Apr-08 9:56
stephan_00722-Apr-08 9:56 
well the input could be anything.
the only difference between the two lines is, one has an additional "1" at the end of every fieldname. so if you remove the last "1" from the second line, then you will get the other.

e.g.
name, address1, address2, postalcode, city, phone_1, phone_2
name1, address11, addrress21, postalcode1, city1, phone_11, phone_21

So as you might have realized the second line is the first one with an additional "1" at the end of each entry.

i guess meanwhile i found a solution to this problem:

first check if every entry ends with 1, then it's the of the second type.
if it is of the second type, then remove the last "1" by using Substring with the whole string without the last character (length-1).
The last operation will change name1 to name and so on.

But if the first operation returns, not every item has a "1" at it's end, then its of type line 1 and nothing has to be done.

in code its something like

string[] Checkforcolorsign (string[] input)
{
  int counter = 0;
  int i = 0;
  // check for "1" at the end (colorinfo)
  while (i < input.length - 1)
  {
    if (input[i].EndsWith("1"))
    {
      counter++; 
    }
  }
  // if all elements had a "1" then it is a colorinfo => remove it
  if (counter == input.length) //as many hits as elements
  {
    for(i=0; i < input.length - 1; i++)
    {
      // remove the last character
      input[i] = input[i].SubString(0, input[i].Length - 1); 
    }
  }
  return input;
}


Maybe this code will illustrate what I originally wanted to ask. I hope this code really does what I expect it to.

so if the input is e.g.
name1, address11, addrress21, postalcode1, city1, phone_11, phone_21

then the final result should be
name, address1, address2, postalcode, city, phone_1, phone_2
GeneralRe: problems splitting string Pin
Guffa22-Apr-08 13:27
Guffa22-Apr-08 13:27 
GeneralRe: problems splitting string Pin
WBurgMo22-Apr-08 9:51
WBurgMo22-Apr-08 9:51 
GeneralRe: problems splitting string Pin
stephan_00722-Apr-08 10:48
stephan_00722-Apr-08 10:48 
GeneralWord plugin - working button Pin
Vodstok22-Apr-08 5:45
Vodstok22-Apr-08 5:45 
GeneralRe: Word plugin - working button Pin
Spacix One22-Apr-08 9:51
Spacix One22-Apr-08 9:51 
General"Remember my password" in a winforms application Pin
benjymous22-Apr-08 5:16
benjymous22-Apr-08 5:16 
GeneralRe: "Remember my password" in a winforms application Pin
led mike22-Apr-08 8:51
led mike22-Apr-08 8:51 
GeneralRe: "Remember my password" in a winforms application Pin
User 665822-Apr-08 8:59
User 665822-Apr-08 8:59 
General[Message Deleted] Pin
gottimukkala22-Apr-08 4:42
gottimukkala22-Apr-08 4:42 
GeneralRe: Wrong board Pin
Blue_Boy22-Apr-08 4:44
Blue_Boy22-Apr-08 4:44 
GeneralSqlParameter problem Pin
Deian22-Apr-08 3:53
Deian22-Apr-08 3:53 
GeneralRe: SqlParameter problem Pin
Blue_Boy22-Apr-08 4:00
Blue_Boy22-Apr-08 4:00 
GeneralRe: SqlParameter problem Pin
Deian22-Apr-08 4:14
Deian22-Apr-08 4:14 
GeneralRe: SqlParameter problem Pin
Blue_Boy22-Apr-08 4:26
Blue_Boy22-Apr-08 4:26 
GeneralRe: SqlParameter problem Pin
Deian22-Apr-08 4:27
Deian22-Apr-08 4:27 
GeneralRe: SqlParameter problem Pin
Blue_Boy22-Apr-08 4:33
Blue_Boy22-Apr-08 4:33 
GeneralRe: SqlParameter problem Pin
Colin Angus Mackay22-Apr-08 10:28
Colin Angus Mackay22-Apr-08 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.