Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static string[] get_word()
- {
- string[] temp = new string[2];
- using (MySqlConnection connection = new MySqlConnection("Database=proj;Data Source=kfreebie.ru; User Id=anagrammist;SslMode=none;Password=YRxDz6aUSTWEiFeo"))
- {
- connection.Open();
- using (MySqlCommand command = connection.CreateCommand())
- {
- command.CommandText = "select wtext from (select wtext from words order by rand() limit 1) kek";
- using (MySqlDataReader reader = command.ExecuteReader())
- {
- try
- {
- reader.Read();
- temp[0] = reader.GetString(0);//0-норм, 1 - мешать
- temp[1] = reader.GetString(0);
- }
- catch
- {
- return temp;
- }
- }
- command.CommandText = string.Format("delete from words where wtext='{0}'", temp[0]);
- command.ExecuteNonQuery();
- }
- connection.Close();
- Random rand = new Random();
- temp[1] = String.Join("", temp[1].OrderBy(x => x).ToArray());
- char[] tempchars = temp[1].ToCharArray();
- tempchars[rand.Next(0, temp[1].Length / 2)] = '*'; tempchars[rand.Next(temp[1].Length / 2, temp[1].Length)] = '*';
- temp[1] = new string(tempchars);
- return temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement