Поясните строку кода с str.ReadToEnd().Split() - C#

Узнай цену своей работы

Формулировка задачи:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Assignment_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = new System.IO.StreamReader(@"D:\2.txt");
            string taan;
            int k = 0;
            string[] split = str.ReadToEnd().Split(new[] { "!", ".", ",", "?", " " }, StringSplitOptions.None);
            string symbols = "eyuioa";
            for (int i = 0; i < split.Length; i++)
            {
                taan = split[i];
                k = split[i].Length - 1;
                if (split[i].Length > 1)
                {
                    for (int h = 0; h < symbols.Length; h++)
                    {
                        if (taan[0] == symbols[h])
                        {
                            for (int u = 0; u < symbols.Length; u++)
                            {
                                if (taan[k] == symbols[u])
                                {
                                    Console.WriteLine(taan);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            Console.ReadKey();
        }
    }
    }
поясните string[] split = str.ReadToEnd().Split(new[] { "!", ".", ",", "?", " " }, StringSplitOptions.None); и весь цикл

Решение задачи: «Поясните строку кода с str.ReadToEnd().Split()»

textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Assignment_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = new System.IO.StreamReader(@"D:\2.txt");
            string[] split = str.ReadToEnd().Split(new[] { "!", ".", ",", "?", " " }, StringSplitOptions.None);
            string symbols = "eyuioa";
            string[] words = split.Where(x => symbols.Contains(x[0]) && symbols.Contains(x[x.Length - 1]) && x.Length > 1).ToArray();
            Console.WriteLine(string.Join("\n", words));
            Console.ReadKey();
        }
    }
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

14   голосов , оценка 3.857 из 5
Похожие ответы