子串数组索引的问题

时间:2011-07-01 15:18:13

标签: c# asp.net

ProfilePageList是字符串数组,每个字符串包含由字符组(#$%)分隔的pageID,PageName和PageContent。这是一个使用C#

的ASP.NET应用程序
            foreach (string item in ProfilePageList)
            {
                string PageContent = ""; string PageName = ""; string PageID = "";

                *** > This part is wrong. Help me here ***

                PageID = item.Substring(0, item.IndexOf('#$%') + 2);
                PageContent = item.Substring(item.IndexOf('#$%') + 1);
                PageName = item.Substring(0, item.IndexOf('#$%'));


                callsomefunction(PageID , PageName, PageContent);  
            }

输入字符串为Helloo#$%<p>How are you??</p>#$%74396

我不明白如何使用这个子字符串。有谁可以帮助我吗!!非常感谢提前..

1 个答案:

答案 0 :(得分:2)

看看这些:

http://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.71).aspx

http://csharp.net-informations.com/string/csharp-string-substring.htm

但我认为你要做的是这样的事情:

string[] substrings = inputString.Split("#$%");

无论如何,您正在使用的数据结构 - 将数据填充到字符串中 - 相当复杂。为什么不只使用适当的物体?