Most efficient way to remove special characters from string

Why do you think that your method is not efficient? It’s actually one of the most efficient ways that you can do it. You should of course read the character into a local variable or use an enumerator to reduce the number of array accesses: One thing that makes a method like this efficient is … Read more

How to download image from URL

Simply You can use following methods. These methods are almost same as DownloadString(..) and DownloadStringAsync(…). They store the file in Directory rather than in C# string and no need of Format extension in URi If You don’t know the Format(.png, .jpeg etc) of Image Using it

How can I wait for a thread to finish with .NET?

I can see five options available: 1. Thread.Join As with Mitch’s answer. But this will block your UI thread, however you get a Timeout built in for you. 2. Use a WaitHandle ManualResetEvent is a WaitHandle as jrista suggested. One thing to note is if you want to wait for multiple threads: WaitHandle.WaitAll() won’t work … Read more

How to pass data (and references) between scenes in Unity

There are many ways to do this but the solution to this depends on the type of data you want to pass between scenes. Components/Scripts and GameObjects are destroyed when new scene is loaded and even when marked as static. In this answer you can find Use the static keyword 1. Use the static keyword. Use this method if the … Read more

‘An exception occurred during a WebClient request” while using C# ASP.NET

I can reproduce this if I specify, as seems to be the case in your example, a folder name rather than a file name the destination. Supply a file name instead. As an aside; if I look at the InnerException, it tells me that the problem relates to the file path: Which gives: If I change it to a file, it works fine:

Categories c# Tags