464,360 Members | 1,313 Online
Need help? Post your question and get tips & solutions from a community of 464,360 IT Pros & Developers. It's quick & easy.

# String length using " "c,10

 P: n/a Can anyone tell me what the "c" means in a statement like this: strTest = New String(" "c,10) I know the 10 in above example stands for the maxlength of characters in the string. Is it posible to skip this maxlength? I'm trying to open a textfile an put it into a string, and therefor I just want to read the whole textfile til EOF. I'm a bit new programming in Visual Basic.NET so I hope you remember that in your answers. Nov 21 '05 #1
9 Replies

 P: n/a "CeyloR" wrote in message news:11********************@g43g2000cwa.googlegrou ps.com... Can anyone tell me what the "c" means in a statement like this: strTest = New String(" "c,10) I know the 10 in above example stands for the maxlength of characters in the string. Is it posible to skip this maxlength? I'm trying to open a textfile an put it into a string, and therefor I just want to read the whole textfile til EOF. I'm a bit new programming in Visual Basic.NET so I hope you remember that in your answers. The "c" following the " means the previous string is converted to a character :) HTH, Mythran Nov 21 '05 #2

 P: n/a Mythran wrote: The "c" following the " means the previous string is converted to a character :) Not exactly. It means that it is a character constant as opposed to a string constant. No conversion takes place. strTest = New String(" "c,10) The same thing can be achieved with this line: Dim strTest As String = " " '<--Note there are 10 spaces Nov 21 '05 #4

 P: n/a "CeyloR" schrieb Can anyone tell me what the "c" means in a statement like this: strTest = New String(" "c,10) I know the 10 in above example stands for the maxlength of characters in the string. Is it posible to skip this maxlength? I'm trying to open a textfile an put it into a string, and therefor I just want to read the whole textfile til EOF. I'm a bit new programming in Visual Basic.NET so I hope you remember that in your answers. http://msdn.microsoft.com/library/en...BSpec2_4_5.asp Armin Nov 21 '05 #5

 P: n/a "Chris Dunaway" schrieb Mythran wrote: The "c" following the " means the previous string is converted to a character :) Not exactly. It means that it is a character constant as opposed to a string constant. No conversion takes place. strTest = New String(" "c,10) The same thing can be achieved with this line: Dim strTest As String = " " '<--Note there are 10 spaces It's a literal, not a constant. You need the 'Const' keyword to declare a constant. Armin Nov 21 '05 #6

 P: n/a Thanks all for the fast and clear replies. @Michel Posseth: The method to read a whole textfile works great! Nov 21 '05 #7

 P: n/a CeyloR, In addition to the other comments: " "c is a character literal. http://msdn.microsoft.com/library/de...BSpec2_4_5.asp While " " is a string literal. http://msdn.microsoft.com/library/de...BSpec2_4_4.asp A "constant" is "a constant value that is a member of a type". http://msdn.microsoft.com/library/de...fVBSpec7_4.asp Although it *is* common practice to refer to literals as constants. Constants don't have to be literals, they can be expressions... Hope this helps Jay "CeyloR" wrote in message news:11********************@g43g2000cwa.googlegrou ps.com... | Can anyone tell me what the "c" means in a statement like this: | | strTest = New String(" "c,10) | | I know the 10 in above example stands for the maxlength of characters | in the string. Is it posible to skip this maxlength? | | I'm trying to open a textfile an put it into a string, and therefor I | just want to read the whole textfile til EOF. | | I'm a bit new programming in Visual Basic.NET so I hope you remember | that in your answers. | Nov 21 '05 #8

 P: n/a Hmm... Why not use the StreamReader's ReadToEnd function? Nov 21 '05 #9

 P: n/a Yep you are right didn`t thought of that because i normally need to parse my files line by line ( was a copy paste action ) but indeed if you do not need to parse anything and just need to read it in one operation to a string the readtoend option is better regards Michel Posseth "Dragon" wrote in message news:OH**************@TK2MSFTNGP09.phx.gbl... Hmm... Why not use the StreamReader's ReadToEnd function? Nov 21 '05 #10

### This discussion thread is closed

Replies have been disabled for this discussion.