我是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) 我想每次在线读取文件"hello.txt",然后将此行写入"bye.text"并进入屏幕.我怎样才能做到这一点?我在"文件"中看到的唯一功能是:
我试图更好地理解c#中的抽象类.
我知道在抽象类中你必须覆盖抽象方法并且可以覆盖虚方法.
我的问题是:
我可以覆盖非虚拟方法吗?(我知道通常我不能 - 但也许抽象类不同?)或者它会隐藏吗?
另外,正如我在这里读到的如何强制调用C#派生方法(第一个答案) - 在我看来,因为非虚拟方法在编译时静态链接而且无法更改 - 我无法调用方法在派生类中,从来没有?如果是这样 - 隐藏方法有什么意义?