Convert from %20 to normal character (replace) [duplicate] - c#

This question already has answers here:
decode percent-encoded string c# .net
(4 answers)
Closed 7 years ago.
I've searched for this and cannot find any hint anywhere.
Basically there is a program that formats their file name like this
hello%20world%28hello%20world%29
which is supposed to mean hello world(hello world)
now im wondering is there any way that I could read every file name and anything that uses "%ascii" would be converted to normal text (e.g above).
Thanks in advance guys. I'm not that experienced in code and I'm hoping that someone could help me.

Use System.Uri.UnescapeDataString:
Uri.UnescapeDataString("hello%20world%28hello%20world%29");
Prints:
hello world(hello world)

Related

Removing Quotes and escaped quotes from string value [duplicate]

This question already has answers here:
C# String.Replace double quotes and Literals
(4 answers)
Closed 1 year ago.
I'm having a really embarrasing moment, as this feels like it's super simple but I just cannot seem to figure out what the best solution is, (or one at all for that matter).
I have a string like so:"\"123456\""
I want 123456
In C#, what is the quickest and easiest way of getting just the value from this? I've looked into using the Regex class and tried the .Unescape() method but I seem to have no success. Please help.
#CharlieFace's answer was the answer that worked for me.
string.Trim('\ "')
Thank you!

Using default File Symbols in C# [duplicate]

This question already has answers here:
Get the icon for a given extension
(4 answers)
Closed 7 years ago.
I want that a user can enter a filename and it shows him the "symbol" of the file.... like those ones:
I know that I could extract them out of their dlls and add them to my project, but I think there could be a solution which grabs them out of windows...
I would like to have a very simple implementation, because it'll be part of a school project and the examiners hate importing DLLs, it would be "unsafe", so , a function which is supported by C#'s default stuff would be very nice for me.
I found something that is much much much easier than importing DLLs or such higher things.
Icon.ExtractAssociatedIcon(filename);
it returns an icon, so you have to convert it to an Image:
(Image)new ImageConverter().ConvertFrom(Icon.ExtractAssociatedIcon(filename));
It even extracts icons of .exe 's, which is even more than I asked for.
I'm really happy that I can provide an easier answer. Thanks Stackoverflow ☺

How to search for a string in a text file? [duplicate]

This question already has answers here:
Text file parsing - how can I search for a specific string and return whole line?
(3 answers)
Closed 8 years ago.
How do I search for a string in a text file line. And if found save it as a string variable...
I need an example if possible. I have tried to do it but couldn't do it. I can't post what I have tried because I'm stupid and deleted it. Any help is appreciated. Thanks in advance! :)
I know this page thats explain how search for a specific string and return whole line.
Its can help you...
See the link:
Text file parsing - how can I search for a specific string and return whole line?
Thaks.

How to convert 26750 string to 26,750 format in c# [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
.NET String.Format() to add commas in thousands place for a number
Hi Guys,
I have got 26750 in my string variable, something like below:
string str = "26750";
Now before showing on page, I want it to be converted into "26,750" format using c#. This value can increase as well as decrease also according to the result, so my format should work in both the cases.
Please suggest!
EDIT:
As I have written I have got string type value in my variable, I am trying with below code, but it is not working for me.
spnMiles.InnerHtml = String.Format("{0:n}", Miles);
It is not changing to the number format.
Please suggest!
This question should answers yours:
.NET String.Format() to add commas in thousands place for a number

Realtime complination in C# [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Is there a method that will evaluate a string and produce an integer (assuming the string is an equation) in C#
Hi all, i just wonder how to make a realtime complination in C#
For example: i have a string like this
string math = "1 + 2 + (4 - 6)";
And i want to complie it to get the result
How to do that? and is that the bad idea because i want to make a calculator in C#?
Edited:
The main question properly is that i want to do it in WP7, not exactly in C# windows lol, i tried all the solutions below but not at all is correct!
and is that the bad idea because i want to make a calculator in C#?
One problem with that is that your calculator language is probably supposed to be just a subset of C#. So using the C# compiler may be too flexible and allow arbitrary C#. Kind of like problems with SQL injection attacks.
Expresion Evalution is an application of STACK (Data Structure)
You can see these link If you want Sample projects
http://www.vbforums.com/showthread.php?t=397264
http://www.codeproject.com/KB/cs/runtime_eval.aspx
http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx

Categories