Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试制作一个 C# 代码以从记事本文件中读取,那么如何将它逐字存储在数组中或如何使其读取并停止在某个特殊标记处? 例如 read$ from$ file$ 并且它应该存储在数组中作为 从 文件中 读取
File.ReadAllLines("file.txt").Split("$")
使用以下代码。
String[] tokens = File.ReadAllText("file.txt").Split('$');
令牌字符串数组将为您提供所需的字符串值。
按你说的保存。在使用“$”检索拆分数据时。它会给你数组。
string[] strarr = mytxtdata.Split('$');