Removing HTML tags from string C# ASP


Here is the simple C# program that is used to remove HTML tags from a string, with very simple while and if else statement.
Here is code (C# function):
public static string RemoveHtmlTags(string content){
            char[] array = new char[content.Length];
            int arrayIndex = 0;
            bool inside = false;

            for (int i = 0; i < content.Length; i++)
            {
                char let = content[i];
                if (let == '<')
                {
                    inside = true;
                    continue;
                }
                if (let == '>')
                {
                    inside = false;
                    continue;
                }
                if (!inside)
                {
                    array[arrayIndex] = let;
                    arrayIndex++;
                }
            }
            return new string(array, 0, arrayIndex);
}
thanks g.
:)

0 comments:

Post a Comment