I wish to know is there any code in C# to pick up predetermined characters from random input.
Suppose we say predetermined characters are "Address"
Random console input is 3545325Adggfdgdfgd3!@$@@#rsfssefas&*acs.
Program will realise there are A, d, d, r, e, s, and s letters in it and pick up and return it.
Predetermined characters
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K pointsPosted Sep 7, 2013, 2:20 AM EDT
How about doing it this way:
-------------------------------------------------------------------
string inputStr = "3545325Adggfdgdfgd3!@$@@#rsfssefas&*acs"; string checkStr = "Address"; List<char> FoundChars = new List<char>(); if (!string.IsNullOrEmpty(inputStr)) { foreach (char c in checkStr) { if (inputStr.IndexOf(c) > -1) { FoundChars.Add(c); continue; } } foreach (char c in FoundChars) { Console.Write(c); } } ------------------------------------------------------------------------- Hope it helps :)Former memberPosted Sep 7, 2013, 3:22 AM EDT
Modification is character must be the i/p from the keyboard. Which is
string inputStr = Console.ReadLine();
2 short replies
Former memberPosted Sep 7, 2013, 3:12 AM EDT
Sunny SharmaRank #223 · 11.1K pointsPosted Sep 7, 2013, 3:15 AM EDT