B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it
Please try below code it will work with any string that have . as separator.
class Program
{
public static string test = "a.b.c";
static void Main(string[] args)
{
var array = test.Split(new char[]{'.'}, StringSplitOptions.RemoveEmptyEntries);
string result = string.Join("\".\"", array);
result = "\"" + result + "\"";
Console.WriteLine(result);
Console.Read();
}
}
Member
3 Points
14 Posts
replacing with double quotes
Feb 09, 2015 11:18 PM|xavier.r.fernando|LINK
can someone please send the csharp code to convert the first string like the second one
a.b.c
"a"."b"."c"
All-Star
50831 Points
9895 Posts
Re: replacing with double quotes
Feb 09, 2015 11:32 PM|A2H|LINK
You can try with the below code
//Your string string s = "a.b.c"; //Add double quotes string replaced = "\""+ s.Replace(".", "\".\"")+"\""; //This line outputs "a"."b"."c"
Aje
My Blog | Dotnet Funda
Star
14297 Points
5797 Posts
Re: replacing with double quotes
Feb 09, 2015 11:51 PM|gerrylowry|LINK
@xavier.r.fer... TIMTOWTDI
Why would you want to?
Do you simply mean how to code your string?
output:
xavier.r.fer..., some clarification from you would be helpful.
Where is your a.b.c ? in code? in a data file?
http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer
Member
212 Points
39 Posts
Re: replacing with double quotes
Feb 10, 2015 01:20 AM|mayakrunal|LINK
Hi Xavier.r.Fernando,
Please try below code it will work with any string that have . as separator.
With Regards,
Krunal Parekh