Programming Help needed

prabu901104

Member
Nov 7, 2008
1,043
0
0
Sri Lanka The Heaven on Earth
Guys i use Visual Studio C# 2008

I converted an Integer to string to suite my application's need. now I want to count the characters in that string.

I tried "myString.Length" and it showed some unexpected results.

Ex. If myString = "12345" myString.Length outputs "4" WTF?

I need some advice from PRO's in EK... Please Help!
 

Jack_Sparrow

Well-known member
  • Jun 16, 2008
    42,522
    1
    16,927
    113
    Black Pearl
    myString kiyaana ekanee variable eka String ekak widiyata declare karala mehema

    String myString = "12345";



    Console.WriteLine("{0}",myString.Length);


    karala balanna kiyada display wenne kiyala
     

    Jack_Sparrow

    Well-known member
  • Jun 16, 2008
    42,522
    1
    16,927
    113
    Black Pearl
    madurax86 said:
    try the same property for other strings
    if you get the length -1 then get the length by adding one :P

    eeka tamai maath mee kiyanna heduwe nkan string ekak widiyata declare karala size 1 balanna kiyala ;)
     

    madurax86

    Member
    Jun 29, 2006
    4,385
    88
    0
    prabu901104 said:
    I tried that. no luck. for "1234" it outputs "3" for "2345" it outputs "4" :no::no::no:

    may be its the number, why put a number in a string?? LOL
    try reseting mem before calling the length property
    that might work if not its a glitch in C# or just try with some alphabetic characters i think that'll work
     

    madurax86

    Member
    Jun 29, 2006
    4,385
    88
    0
    prabu901104 said:
    Still no luck :(
    jump to vb6 :P
    or make the big one jump to the open world use the mingw32 c++ compiler dump MS shit, two things they made right was VC++ 6 and VB 6 those IDEs are used even today .NET is bullsh!t - i mean it i've been a programmer about 6 years I haven't seen better IDEs from MS than those two!:cool:
     

    ¤--bACarDi--¤

    Well-known member
  • Jan 9, 2009
    12,130
    288
    83
    124.43.xxx.xxx
    First of all....My C# knowledge sucks...!!!
    Bt in most languages Strings are save as Character Array.... At last it saves "Null" for the end of word....So "1234" Contains 5 Characters with "Null"....
    So i think somthing wrong with that incident.....
     

    madurax86

    Member
    Jun 29, 2006
    4,385
    88
    0
    ¤--bACarDi--¤ said:
    First of all....My C# knowledge sucks...!!!
    Bt in most languages Strings are save as Character Array.... At last it saves "Null" for the end of word....So "1234" Contains 5 Characters with "Null"....
    So i think somthing wrong with that incident.....
    it is right for c++, c but c# is MS stuff they do it their style ;):rofl:
     

    Ranhiru

    Member
    Feb 2, 2007
    6,438
    42
    0
    Inside FIREFOX
    Code:
     Dim s As String
     s = InputBox("Enter String")
    
     MsgBox(s.Length)

    This works fine in my PC... or are u doing a console application?
    Or has the problem being already solved?