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?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Akhil MittalRank #133 · 16.9K reputationPosted Jun 25, 2014, 8:56 PM EDT
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
Nilesh Sanyal191 reputationPosted Jun 26, 2014, 1:41 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 26, 2014, 9:16 AM EDT