Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3.  
  4. namespace Collections
  5. {
  6. class Class1
  7. {
  8. public static int[] arr1 = new int[] {1,2,3,4};
  9. public static string s = "";
  10. public static string opt = "y";
  11.  
  12. static void Main(string[] args)
  13. {
  14. while ((opt == "y")|| (opt == "Y"))
  15. {
  16. Console.Write("Enter Your name :");
  17. s = Console.ReadLine();
  18. IEnumerator IEn = s.GetEnumerator();
  19. Array a = Array.CreateInstance(typeof(char),s.Length);
  20. Console.WriteLine("Type :{0}",IEn.GetType());
  21. Console.WriteLine("HashCode for the Type:{0}",(IEn.GetHashCode()));
  22. IEn.Reset();
  23. IEn.MoveNext();
  24. for(int i = 0; i < s.Length ; i++)
  25. {
  26. a.SetValue(IEn.Current,i);
  27. IEn.MoveNext();
  28. }
  29. Array.Sort(a);
  30. Console.Write("Your Name in the sorted form : ");
  31. for(int i = a.GetLowerBound(0);i<=a.GetUpperBound(0); i++)
  32. {
  33. Console.Write(a.GetValue(i));
  34. }
  35. Console.WriteLine("");
  36. Console.Write("Do You want to try again?(y/n): ");
  37. opt = Console.ReadLine();
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement