Замена символов в строке - C# (180509)
Формулировка задачи:
В строке нужно заменить "пробел точка" на "пробел запятая"
Cделал на сравнение смог найти количество не особо понимаю как провести замену подскажите
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{ int b = 0;int count = 0;
string str = textBox1.Text;
string find = " .";
for (int i = 0, j = 0; i < str.Length; i++)
{
if (str[i] == find[j]) // тут
{
j++;
}
else // и тут
j = 0;
if (j == find.Length)
{
count++;
j = 0;
}
}
textBox3.Text =find+' '+count.ToString();
}
}
}Решение задачи: «Замена символов в строке»
textual
Листинг программы
using System;
using System.Linq;
class Program
{
public static void Main()
{
string s = "abracadabra,,, Santa Claus ... ,.Linux.,";
Console.WriteLine(new String(Enumerable.Repeat(s[0], 1).Concat(s.Zip(s.Skip(1), (p, n) => p == ' ' ? n == '.' ? ',' : n == ',' ? '.' : n : n)).ToArray()));
}
}