Calling the base constructor in C#

Modify your constructor to the following so that it calls the base class constructor properly: Note that a constructor is not something that you can call anytime within a method. That’s the reason you’re getting errors in your call in the constructor body.

Input string was not in a correct format

The error means that the string you’re trying to parse an integer from doesn’t actually contain a valid integer. It’s extremely unlikely that the text boxes will contain a valid integer immediately when the form is created – which is where you’re getting the integer values. It would make much more sense to update a and b in the … Read more

MVC5 / C# – Cannot perform runtime binding on a null reference

There are two issues in your code: Consider this: This simplified piece of code throws Cannot perform runtime binding on a null reference since speakers is not defined (null reference). You can fix it by defining speakers in the dynamic ViewBag before the loop: The second issue: speakers in your code is a List, you might want to define ViewBag.speakers as a List<List<string>> and call .Add(speakers) instead … Read more

Randomize a List

Shuffle any (I)List with an extension method based on the Fisher-Yates shuffle: Usage: The code above uses the much criticised System.Random method to select swap candidates. It’s fast but not as random as it should be. If you need a better quality of randomness in your shuffles use the random number generator in System.Security.Cryptography like so: A simple … Read more

EF CodeFirst: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong

This is because of name Conflict of Class (Model) names with other reserved or generated ones, when auto creates the tables and … . Considering that EF Code First creates the intervene tables to relate 2 or more tables using name of tables for derived intervene table, so when you use a class name that employs a … Read more

Creating a comma separated list from IList or IEnumerable

.NET 4+ Detail & Pre .Net 4.0 Solutions IEnumerable<string> can be converted into a string array very easily with LINQ (.NET 3.5): It’s easy enough to write the equivalent helper method if you need to: Then call it like this: You can then call string.Join. Of course, you don’t have to use a helper method: The latter is a bit of … Read more