Считать текст из файла и вывести на экран - C# (181010)
Формулировка задачи:
Считать текст из файла и вывести на экран, заменив цифры от 0 до 9 словами «ноль», «один», ..., «девять», начиная каждое предложение с новой строки.
Как считать текс и вывести на экран разобрался, а вот как заменить цифры нет. Их свичем надо делать или как? Хелп тупому((
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Lab_8
{
class Program
{
static void Main(string[] args)
{
StreamReader reader = new StreamReader("d:\\file.txt", Encoding.Default);
string[] lines = reader.ReadToEnd().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
reader.Close();
Console.WriteLine();
Console.ReadLine();
}
}
}Решение задачи: «Считать текст из файла и вывести на экран»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Lab_8
{
class Program
{
static void Main(string[] args)
{
StreamReader reader = new StreamReader("d:\\file.txt", Encoding.Default);
string[] lines = reader.ReadToEnd().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
string text = "1 2 3 check9 hello 3";
text = text.Replace("0", "ноль");
text = text.Replace("1", "один");
text = text.Replace("2", "два");
text = text.Replace("3", "три");
text = text.Replace("4", "четыре");
text = text.Replace("5", "пять");
text = text.Replace("6", "шесть");
text = text.Replace("7", "семь");
text = text.Replace("8", "восемь");
text = text.Replace("9", "девять");
text = text.Replace(".", "\n");
text = text.Replace("!", "\n");
text = text.Replace("?", "\n");
text = text.Replace("...", "\n");
Console.WriteLine(text);
reader.Close();
Console.WriteLine();
Console.ReadLine();
}
}
}