问题描述
我一直在做我的问题了大量的研究,似乎无法拿出一个很好的解决方案。
I have been doing a lot of research on my problem and can't seem to come up with a good solution.
这个问题我有一个包含以下列表中。
the problem I have a list containing the following
a
a/b
a/b/c
a/b/c/d
a/b/f
a/1
a/2
t
t/1
我需要解析成可以处理父子层次结构中的类。明知任何级别可以有孩子的无限量。
I need to parse that into a class that can handle parent child hierarchy. Knowing that any level can have unlimited amount of children.
任何帮助将appriciated。
Any help would be appriciated.
推荐答案
您输入的格式几乎是相同的SQL Server中的层次结构节点路径字符串。有关分析这些下面的StackOverflow问题可能会非常接近,如果不是你想要什么。
The format of your input is almost identical to the node path strings in Sql Server hierarchies. The following StackOverflow question about parsing those will probably be very close to, if not exactly what you want.
Converting扁平从SQL Server分层数据变成结构化的JSON对象的C#/ LINQ的
这篇关于从字符分隔的字符串层次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!