Friday, January 15, 2021

Q.6: How to remove duplicate characters from a string?

 Ans.: The user will input a string and the method should remove multiple occurrences of characters in the string

  • input: csharpcorner, output: csharpone
internal static void removeduplicate(string str)
{
string result = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (!result.Contains(str[i]))
{
result += str[i];
}
}
Console.WriteLine(result);
}

1 comment:

  1. Excellent Blog, I like your blog and It is very informative. Thank you
    Linux
    Software

    ReplyDelete

Get max value for identity column without a table scan

  You can use   IDENT_CURRENT   to look up the last identity value to be inserted, e.g. IDENT_CURRENT( 'MyTable' ) However, be caut...