Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Remove words string C#

string TrimWordsFromString(string value, int numberOfWords, char separator, bool reverse)
{
	int trimmedWords = 0;
    int index = 0;
    
    while(trimmedWords != numberOfWords)
    {
    	if(value == string.Empty)
        {
        	return string.Empty;
        }
        
        if(reverse)
        {
        	index = value.Length - 1;
        }
        
        if(value[index] == separator)
        {
        	trimmedWords++;
        }
        
        value = value.Remove(index, 1);
    }

    return value;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Remove #words #string
ADD COMMENT
Topic
Name
6+5 =