Открыть файл и вывести вставив каждые 4 символа тире - C#
Формулировка задачи:
В чем ошибка?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Plastikovaya_karta
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Ввод номера пластиковой карты:"); //Открытие файла
string path = @"input"; //путь
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
for (int i = 0; i <= s.Length; i += 4)
s.Insert(i, "-");
Console.WriteLine(s);
}
}
Console.Read();
}
}
}Решение задачи: «Открыть файл и вывести вставив каждые 4 символа тире»
textual
Листинг программы
for (int i = 4; i <= 18; i +=5) s = s.Insert(i, "-");