小编nat*_*ati的帖子

如何在没有"printf"的情况下调用Seq.whatever中的函数?

我是f#的新手,我试图编写一个程序,该程序应该遍历给定目录中的所有文件,并为每个类型为".txt"的文件添加一个id号+"DONE"到文件中.

我的节目:

//const:
[<Literal>]
let notImportantString= "blahBlah"
let mutable COUNT = 1.0

//funcs:
//addNumber --> add the sequence number COUNT to each file.
let addNumber (file : string)  =
 let mutable str = File.ReadAllText(file)
 printfn "%s" str//just for check
 let num = COUNT.ToString()
 let str4 = str + " " + num + "\n\n\n DONE"
 COUNT <- COUNT + 1.0
 let str2 =  File.WriteAllText(file,str4)
 file

//matchFunc --> check if is ".txt"
let matchFunc (file : string) =
 file.Contains(".txt") 

//allFiles --> …
Run Code Online (Sandbox Code Playgroud)

f# sequences seq

2
推荐指数
1
解决办法
1309
查看次数

如何从C#中的文本文件一次读/写一行

我想每次在线读取文件"hello.txt",然后将此行写入"bye.text"并进入屏幕.我怎样才能做到这一点?我在"文件"中看到的唯一功能是:

  • readAllText
  • readAllLines
  • WriteAllLines等

file-io f# file

1
推荐指数
1
解决办法
4546
查看次数

抽象方法和隐藏方法

我试图更好地理解c#中的抽象类.

我知道在抽象类中你必须覆盖抽象方法并且可以覆盖虚方法.

我的问题是:

我可以覆盖非虚拟方法吗?(我知道通常我不能 - 但也许抽象类不同?)或者它会隐藏吗?

另外,正如我在这里读到的如何强制调用C#派生方法(第一个答案) - 在我看来,因为非虚拟方法在编译时静态链接而且无法更改 - 我无法调用方法在派生类中,从来没有?如果是这样 - 隐藏方法有什么意义?

c# abstract-class method-hiding

1
推荐指数
1
解决办法
1685
查看次数

标签 统计

f# ×2

abstract-class ×1

c# ×1

file ×1

file-io ×1

method-hiding ×1

seq ×1

sequences ×1