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
Linq FirstOrDefault() null check in c#
RGEFCSZX
Inheritiance
іфи
Dokkan Awaken Calculator 1.1
HelloWorld
2 3
eg
числата от 1 до 20
Print 2D Array