sscanf

  • Thread starter Thread starter Hin
  • Start date Start date
H

Hin

Anyone knows if there is any method similar to the C++ sscanf in C#?
(parse a string that contains several values)
 
Theres no statement exactly like scanf. StreamReader is pretty good class to
read file

System.IO.StreamReader stream = new StreamReader(testFileName);
stream.BaseStream.Seek(0, SeekOrigin.Begin);
while (stream.Peek() > -1)
{
stream.ReadLine(); //equal to scanf
}
stream.Close();
 
Regular expressions are a quite powerful technique to extract data from a
string. And, most simple types have a Parse method (int.Parse,
double.Parse...). IMO a combination of those two comes closest to "scanf"
(but it more powerful and safer)

Niki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Incrementing IPv6 address 1
sscanf in c# 20
Help parsing string 3
convert string to double and count characters 6
sscanf 3
scanf or sscanf 3
Simulating sscanf parsing in C# 4
Beginning C# 3

Back
Top