I have a program, and I'm trying to remove duplicate characters. I have tried using toLower(), but it doesn't work...I'm not sure where to go from here. Any help in the right direction would be great!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SortingLetters
{
static class RandomLetter
{
static Random _random = new Random();
public static char GetLetter()
{
// This method returns a random lowercase letter.
int num = _random.Next(0, 26); // Zero to 25
char let = (char)('a' + num);
return let;
}
}
class SortingLetters
{
static void Main()
{
int max = 30;
List<char> items = new List<char>();
int counter = 0;
// Get random lowercase letters.
while (counter < max)
{
counter++;
items.Add(RandomLetter.GetLetter());
}
// ascending order
var itemSorted =
from it in items
orderby it ascending
select it;
// writes ascending order to console
foreach (var element in itemSorted)
Console.Write("{0}", element);
Console.Write("\n");
// descending order
var itemDescend =
from it in items
orderby it descending
select it;
// writes ascending order to console
foreach (var element in itemDescend)
Console.Write("{0}", element);
Console.Write("\n");
}
}
}
`