Problem with Index of in Substring array
ProfilePageList is the string array with each string containing pageID, PageName and PageContent separated by group of characters (#$%). This is a ASP.NET application using C#
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);
}
开发者_开发问答
Input string is Helloo#$%<p>How are you??</p>#$%74396
I dont understand how to use this substring. Can someone help me Please!! Thanks a lot in advance..
Have a look at these:
http://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.71).aspx
and
http://csharp.net-informations.com/string/csharp-string-substring.htm
But I think what you're trying to do is something like this:
string[] substrings = inputString.Split("#$%");
Anyway, the data structure you are using -- cramming data into strings -- is rather convoluted. Why not just use proper objects?
精彩评论