i want to split a string into char
that is my string
"the stack overflow in very good website"
and i want to convert this string
like
first word and second split into character
the.. .. .. t.. ..h.. ..e.. .. stack.. .. ..s.. ..t.. ..a.. ..c.. ..k.. .. overflow.. .. ..o.. ..v.. ..e.. ..r.. ..f.. ..l.. ..o.. ..w.. .. in.. .. ..i.. ..n.. .. very.. .. ..v.. ..e.. ..r.. ..y.. .. good.. .. ..g.. ..o.. ..o.. ..d.. .. website.. .. ..w.. ..e.. ..b.. ..s.. ..i.. ..t.. ..e.. ..
i am using natural Reader software and making a dictation mp3 file with spelling
that is my program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace file
{
class Program
{
public static string fileLoc = @"C:\Users\Administrator\Desktop\sample1.txt";
public static string s;
public static string data = "the stack overflow in very good website";
private static void Main(string[] args)
{
Create_File();
Wrint_in_File();
Read_file();
add_comma();
s = Console.ReadLine();
}
public static void Wrint_in_File()
{
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine(data);
Console.WriteLine("Data is successfully save in File");
}
}
}
public static void Create_File()
{
FileStream fs = null;
if (!File.Exists(fileLoc))
{
using (fs = File.Create(fileLoc))
{
Console.WriteLine(@"File is Successfully Created at C:\Users\Administrator\Desktop\sample1.txt");
Console.ReadLine();
}
}
}
public static void Read_file()
{
if (File.Exists(fileLoc))
{
using (TextReader tr = new StreamReader(fileLoc))
{
string s= tr.ReadToEnd();
Console.WriteLine(s);
Console.ReadLine();
}
}
}
public static void add_comma()
{
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.WriteLine(DateTime.Now);
string txt =data.Replace(" ", ".. .. .. .. .. .. .. ..");
sw.WriteLine(txt);
Console.WriteLine(txt);
}
}
}
}
}
using LINQ you can do:
string str = "the stock overflow in very good website";
string separator = "...";
string joinedString = string.Join("", (str.Split()
.Select(r=> r + separator +
(string.Join(separator, r.ToCharArray()))
+separator)));
Console.WriteLine(joinedString);
(By the way its stack overflow)
Ouput would be:
the...t...h...e...stock...s...t...o...c...k...overflow...o...v...e...r...f...l.. .o...w...in...i...n...very...v...e...r...y...good...g...o...o...d...website...w. ..e...b...s...i...t...e...
(Remember to include using System.Linq;
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With