c# - How can I delete all the comments in my code? -
i'm new c#, , want develope program delete comments after //
in code. there simple code recommended purpose?
first point, seems bad idea. comments useful.
taking exercise,
edit: simple solution fail on case @bubbafat mentions (and propbably more). still work ok on source files.
- read text 1 line @ time.
- find last occurrence of
//
, if usingstring.lastindexof()
- remove text after (including) '//' when found
write line output
- ad 1: can open textreader using
system.io.file.opentext()
, orfile.readlines()
if can use fx4 - also open output file using
system.io.file.writetext()
- ad 3:
int pos = line.lastindexof("//"); if (pos >= 0) { line = line.substring(0, pos); }
- ad 1: can open textreader using
Comments
Post a Comment