Remove element from a string
How can I create a method called delete(String str,int m) that returns the input string with the mth element removed?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jun 26, 2014, 1:16 PM
Nilesh SanyalPosted Jun 26, 2014, 5:41 AM
Akhil MittalPosted Jun 26, 2014, 12:56 AM
public static T[] RemoveAt
{
int count = array.Length - 1;
T[] result = new T[count];
if (index > 0)
Array.Copy(array, 0, result, 0, index - 1);
if (index < size)
Array.Copy(array, index + 1, result, index, size - index);
return result;
}
But if you want to remove a string at particular position in a string, you will have to specify the length of that item too(that has to be removed).Else everything else following that item will be removed.
http://stackoverflow.com/questions/8963738/remove-single-character-from-a-string