Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Char array to String
Message
 
 
To
28/10/2004 10:28:53
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP1
Miscellaneous
Thread ID:
00955286
Message ID:
00955393
Views:
18
Jay,

Why not use the sr.ReadLine() method which returns a string?

There is also a string constructor that accepts a character array:
// from the help file
// Unicode Mathematical operators
char [] charArr1 = {'\u2200','\u2202','\u200F','\u2205'};
String szMathSymbols = new String(charArr1);
>Hi,
>
>Am I missing something simple? I want to convert an array of type char to a string of what is in the char buffer. This is the "long way", iterating through the char array:
>
>
>StreamReader sr = new StreamReader(cFile);
>
>char[] c = null;
>string cNextLine;
>
>while(sr.Peek() > -1)
>{
>    c = new char[80];
>    sr.Read(c, 0, c.Length);
>
>    cNextLine = "";
>
>    for (int i = 0; i < nRecordLength; i++)
>    {
>        cNextLine = cNextLine + c[i];
>    }
>
>    SomeFunctionUsingString(cNextLine);
>}
>sr.Close();
>
>
>Is there an easier way provided by the framework?
>
>Thanks,
>Jay
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform