[Solved] C# How to add to list class?

You need to instantiate the Lists in your AddedContacts class’s constructor: public class AddedContacts { private List<CreateContact> Contact; public List<CreateContact> ClassCreateContact { get { return Contact; } set { this.Contact = value; } } public AddedContacts() { Contact = new List<CreateContact>(); ClassCreateContact = new List<CreateContact>(); } } You also need to create an instance of … Read more

[Solved] Unhandled exception when calling object

You need to change your constructor to look at location instead of userLocation (see below) in order to avoid this exception: public FSCServerLocator(string location) { if (string.IsNullOrWhiteSpace(location)) { throw new Exception(“No location included at initialization”); } //parameter filtering userLocation = location; } 2 solved Unhandled exception when calling object

[Solved] Incorrect syntax near ‘79000’ [closed]

Change your sql statement to cmd.CommandText = “SELECT CMC, [Site Name], [Phone Number], Zip_Code FROM site Where Zip_Code=”” + Zipcode.Text + “””; You are missing the = which is needed for the syntax to be correct. But you should think about using parameter instead to avoid SQL Injection. Why do we always prefer using parameters … Read more

[Solved] AWAIT multiple file downloads with DownloadDataAsync

First, you tagged your question with async-await without actually using it. There really is no reason anymore to use the old asynchronous paradigms. To wait asynchronously for all concurrent async operation to complete you should use Task.WhenAll which means that you need to keep all the tasks in some construct (i.e. dictionary) before actually extracting … Read more

[Solved] Working with ICollection. Convert to Dictionary

If I understand your question correctly, you want to use that SuperAwesomeNinjaMethod with the indicated signature, and for the second argument, you want to pass an instance of System.Collections.Generic.Dictionary<TKey, TValue>, right? The Dictionary class implements the ICollection interface, hence you can just pass your Dictionary instance. You will get a collection of KeyValuePair<TKey, TValue> solved … Read more

[Solved] Regex to match url not for certain file types

You need to use a lookbehind for that, try http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=;]*)?(?<!jpg)(?<!gif)(?<!doc)$ You need also the anchor $ at the end, it matches the end of the string, that is important to define clearly the point from where the lookbehind should look behind. See it here on Regexr 1 solved Regex to match url not for … Read more

[Solved] SSRS report parameter

A few things to check: SetParameters takes IEnumerable<ReportParameter> not a single ReportParameter object. Call it like this instead: serverReport.SetParameters(new ReportParameter[] { ReportParameter(“dt1”, date.ToString()) } ); Make sure that the parameter does not have the available values filled in as well as the default value. If the date passed is not one of the valid values … Read more

[Solved] Regular Expression to remove leading and trailing Angle Brackets

Why do you need to use Regex for this? You can simply do this: string email = “<[email protected]>”; email = email.TrimStart(‘<‘).TrimEnd(‘>’); Of course if you really need to be sure there’s no spaces, or that there might be multiple spaces: string email = “<[email protected]>”; email = email.Trim().TrimStart(‘<‘).TrimEnd(‘>’); solved Regular Expression to remove leading and trailing … Read more

[Solved] In C#, String .Replace wont replace danish chars

Most Unicode characters have multiple versions that can look very alike. For example: 1????1①⑴ var s = “æӕ”.Replace(“æ”, “ae”); // s = “aeæ” var v = “æӕ”.Select(c => (int)c).ToArray(); // { 230, 1237 } I consider it a good practice to expect the unexpected (especially when it comes to user input) var s = “æӕ”; … Read more

[Solved] The c# of this JavaScript “regex replace”? [closed]

C# has a static method for matching for replacing a string treated as a pattern on the fly: text = Regex.Replace(Regex.Replace(text, @”[^>]+”, “”), @”[,:;()/&+]|–“, ” “); The Regex.Replace method automatically does a global replace. solved The c# of this JavaScript “regex replace”? [closed]

[Solved] How Much Faster is StringBuilder respect of concat operator + in C# .Net [duplicate]

The Microsoft Developer Network has a great comparison: Although StringBuilder and String both represent sequences of characters, they are implemented differently. String is an immutable type. That is, each operation that appears to modify a String object actually creates a new string. For example, the call to the String.Concat method in the following C# example … Read more