escaping from double quote string [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have string "my string" taken from excel value, I used GemBox.Spreadsheet library. But the result I have """my string""". How to get back my real string value as "my string
Thanks

Use the hex escape \x22 such as:
Console.WriteLine ("\x22Literally\x22");
Outputs "Litterally"

okay I just go to GemBox Convert I try upload my excel file, then convert into csv file, and the result is same as my convert file. So the problem is not coming from my script but in GemBox.Spreadsheet library. Thank you for your participate guys!

Related

How to edit CSV data in C# like 1234567 to 123-4567? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
Im trying to edit a postcode data which comes as for example 1234567 and i want to put a dash between 123 and 4567 (e.g 123-4567) is it possible to do this within C# without editing the csv file itself?
Im using a generic for loop to read through the csv file but i want to edit it like i asked above.
foreach(string line in csvData_){
string[] col = line.Split(',');
deliveryAddress.Text = col[0];
deliveryPostcode.Text = col[1];
deliveryPostcode contains 1234567 for e.g.
To solve your problem, you can use the method Insert() of the string object.
For example:
deliveryPostcode.Text = col[1].Length == 7 ? col[1].Insert(3, "-") : col[1];
You have to fit it for your needs, but this is the way I would use.
Here is the MSDN page of the String.Insert().

How to create .list file in C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I know how to put string list to a .txt file for example:
//nw_TCList is a string list
string nwFinal = String.Join("\n", nw_TCList.ToArray());
System.IO.File.WriteAllText(nwPath, nwFinal);
So my question is how to put this string list file to a .list file?
-------------Question update
Thank you for all the reply, nwPath is my txt file address. (#"c:\abc\name.txt")
Problem solved! just change .txt to .list, LOL, i was thinking how to convert txt file to list file before, haha.
.list is just Extension so don't worry about that
there is direct method to write Array to file
System.IO.File.WriteAllLines(nwPath, nw_TCList);
And If you want to have .list Extension
give that in path param
E.g.
System.IO.File.WriteAllLines("D://Data.list", nw_TCList);
that did trick for me

Counting frequency of characters in a line from a .txt file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a C# task to do and I am stuck on part of the coding. I am using StreamReader to read a .txt file which contains group exam grade data (e.g. ADCBCBBBADEBCCBADBAACDCCBEDCBACCFEABBCBBBCCEAABCBB), I need the code to work out how many A's, B's etc there are inside each set of data, I thought about using some form of count++ code but each attempt just throws errors.
I want it to print onto console the number of A's in that line of the .txt file.
I hope that makes sense, I understand how to do the rest but I just needed a hand on this section.
Consider using System.Linq, eg...
string myString = "ADCBCBBBADEBCCBADBAACDCCBEDCBACCFEABBCBBBCCEAABCBB";
int countOfAs = myString.Count(x => x == 'A');
//Result: 9

Windows Phone - Decode ASCII in string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have ASCII encoding characters in string. Something like this:
%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title
How can I decode it to "normal" string? I've tried to find an answer but I find solutions for byte[] of ASCII characters and so. I have an idea that I can replace all characters that starts with % by character which they represents but I think there is better aproach. And one more thing, solution must works for windows phone. Thanks
Use HttpUtility.UrlDecode().
For example, for the string you have given, the result is "{"video":{"JSONinfo":{"id":212096,"title"
You have may alternatives. Choose whichever works for WP
string s = "%7B%22video%22%3A%7B%22JSONinfo%22%3A%7B%22id%22%3A212096%2C%22title";
var s1 = System.Web.HttpUtility.UrlDecode(s);
var s2 = System.Net.WebUtility.UrlDecode(s);
var s3 = System.Uri.UnescapeDataString(s);

Comma-Separated String to Double C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want convert 1,2,3,4,5,6,7,8,9,10 String to Double.
I tried Convert.ToDouble(String); and Double.Parse(String); but returned 1.0
How to convert multi comma string to double?
Thanks for help.
From the looks of your question you actually have 10 numbers not 1. Use this code:
var nums = "1,2,3,4,5,6,7,8,9,10";
var digits = nums.Split(',').Select(r => Convert.ToDouble(r)).ToArray();
// the result will be an array of doubles, also this only works with .NET 3.5 or better.
Let me know if this works for you.

Categories

Resources