Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Remove dublicates
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Text; namespace Rextester { public class Program { public static void Main(string[] args) { var str = "dhhgghjkffyihdyjjgefho"; //Your code goes here Console.WriteLine(RemoveDublicates2("Hello, world!")); } public static string RemoveDublicates(string str){ var result = str.Distinct().ToArray(); return new string(result); } public static string RemoveDublicates2(string str){ var resultBuilder = new StringBuilder(); var set = new HashSet<char>(); // var arr = str.ToCharArray(); foreach(char ch in str){ set.Add(ch); }; return new string(set.ToArray()); } } }
run
|
edit
|
history
|
help
0
xddd
C# Extension Method
Sample
shorten file paths in a commandline using regex
Few Programs that would help in interviews
числата от 1 до 20
Half Sum
10
Random number between 1 - 100 between each value of 10 there will be a differnt message
Learning linq 2