5
Reply

How To Get Largest Number from numbers without using of list or array?

    Where to store the number without using any collection like list or array or dictionary or hashtable and ect..?

    These “numbers” have to be stored in some sort of array or list.

    For all comments the String type itself is an array of chars.

    string s = "1234";int temp = 0;for (int i = 0; i <= s.Length - 1; i++){for (int j = 0; j <= s.Length - 1; j++){if (s[i] > s[j]){temp = s[i];}}}Console.Write(Convert.ToChar(temp));

    you can use substring and loop to find number

    string a = "517378";int max = 0;while (a.ToString().Length > 1){max = Convert.ToInt32(a.Substring(0, 1));a = a.Substring(1, a.ToString().Length - 1);if (max > Convert.ToInt32(a.Substring(0, 1))){a = a.Remove(0, 1).Insert(0, max.ToString());}}MessageBox.Show("Second Max Num is : "+max.ToString());