locked
how to cut string into two parts RRS feed

  • Question

  • I have a string and I want to cau it in two parts

    the string is 16 char , and I want the first eight alone and the second alone

    for example

    string = 1234567855555555

    label1=12345678

    label2=55555555

     

    help me

    Sunday, January 14, 2007 9:11 AM

Answers

  • Hi,

    You need to use the string.SubString() method.

    string full = "1234567855555555";

    string part1 = full.Substring(0, 8);

    string part2 = full.Substring(8, 8);

    Greetz,

    Geert

     

    Geert Verhoeven
    Consultant @ Ausy Belgium

    My Personal Blog

    Sunday, January 14, 2007 9:53 AM

All replies

  • Hi,

    You need to use the string.SubString() method.

    string full = "1234567855555555";

    string part1 = full.Substring(0, 8);

    string part2 = full.Substring(8, 8);

    Greetz,

    Geert

     

    Geert Verhoeven
    Consultant @ Ausy Belgium

    My Personal Blog

    Sunday, January 14, 2007 9:53 AM
  • As suggested by geert,

    You can use Substring function to tear out a string in different sub strings based on index and/or character count.

    But if you need to tear out a string after some specific character's occurance then you can use String.Split function. You can specify after which character's/string's occurrance it should split the string to multiple sub string.

    I hope this will help.

    Best Regards,

    Rizwan aka RizwanSharp

    Sunday, January 14, 2007 12:51 PM
  •  RizwanSharp wrote:

    As suggested by geert,

    You can use Substring function to tear out a string in different sub strings based on index and/or character count.

    But if you need to tear out a string after some specific character's occurance then you can use String.Split function. You can specify after which character's/string's occurrance it should split the string to multiple sub string.

    I hope this will help.

    Best Regards,

    Rizwan aka RizwanSharp

     

    thanks for your addition .. surely it is helpful

    Sunday, January 14, 2007 1:14 PM
  • thank you!!!!

     

    Thursday, January 17, 2008 11:51 AM