使用“fscan”在C#中等效 [英] Using "fscan" Equivalent in C#

查看:90
本文介绍了使用“fscan”在C#中等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C#从ascii

文本文件中读取以下混合数据类型条目。这可以使用fscanf在C中轻松执行。

C#中有等效函数吗?

1 2 1201 1 -0.417597000000000D + 06 0.129600000000000D + 06

0.0 0.753000000000000D + 03 0.198800000000000D + 04

马拉松运动员

I would like to read the following entries of mixed data types from a ascii
text file using C#. This can be easily performed in C using fscanf. Is
there an equivalent function in C#?
1 2 1201 1 -0.417597000000000D+06 0.129600000000000D+06
0.0 0.753000000000000D+03 0.198800000000000D+04
Marathoner

推荐答案

不,与fscanf的方法不同。

您需要阅读该行并使用模式匹配来解析类型上的行


-

WBR,Michael Nemtsev [.NET / C#MVP ]。

博客: http://spaces.live.com/ laflour


" marathoner"写道:
No, there is not the same method as fscanf.
You need to read the line and use pattern matching to parse line on types

--
WBR, Michael Nemtsev [.NET/C# MVP].
Blog: http://spaces.live.com/laflour

"marathoner" wrote:

我想使用C#从ascii

文本文件中读取以下混合数据类型条目。这可以使用fscanf在C中轻松执行。

C#中有等效函数吗?


1 2 1201 1 -0.417597000000000D + 06 0.129600000000000D + 06

0.0 0.753000000000000D + 03 0.198800000000000D + 04


Marathoner
I would like to read the following entries of mixed data types from a ascii
text file using C#. This can be easily performed in C using fscanf. Is
there an equivalent function in C#?
1 2 1201 1 -0.417597000000000D+06 0.129600000000000D+06
0.0 0.753000000000000D+03 0.198800000000000D+04
Marathoner


//您需要阅读该行并使用

类型的解析线模式匹配


如果这样的任务可以更简单,那就不好了吗?
//You need to read the line and use pattern matching to parse line on
types

wouldn''t'' it be good if such task could be done simpler?


11月26日晚上8:54,Lev Elbert< elbert ... @ hotmail.comwrote:
On Nov 26, 8:54 pm, Lev Elbert <elbert...@hotmail.comwrote:

//你需要读取行并使用模式匹配来解析行

类型


如果这样的任务可以更简单,那就不好了?
//You need to read the line and use pattern matching to parse line on
types

wouldn''t'' it be good if such task could be done simpler?



知道>>

运算符和scanfs的奇迹的C和C ++的人发现很难相信在Java和C#中没有类似的,简单易用的设施。有很多小项目

尽可能模拟它。我建议搜索

CodeProject。

People who have been around C and C++ who know about the wonders of >>
operators and scanfs find it hard to believe there is not a similar,
easy facility in Java and C#. There are a lot of small projects that
simulate it as best as possible. I would recommend a search on
CodeProject.


这篇关于使用“fscan”在C#中等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆