Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Only unique chars into string?
//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; namespace Rextester { public class Program { public static void Main(string[] args) { var str = "This is not supposed to be a unique string."; //var str = "String"; // Method 1 var checkedChars = new List<char>(); var result = true; foreach(char c in str){ if(!checkedChars.Contains(c)) checkedChars.Add(c); else{ result = false; break; } } // Method 1 var result2 = str.Distinct().Count() == str.Length; // Throw results. Console.WriteLine("Is unique the list of chars in string? {0}, {1}", result, result2); } } }
run
|
edit
|
history
|
help
0
a
Coding
sintildes
sss
Recursion
Fibonacci with Given Length
gd
codejam1a1
N
Hehd