0 Comments
When you upgrade to Visual Studio 2017, you will notice that the 'Collapse all' (CTRL+M, CTRL+O) functionality doesn't collapse the regions anymore. This is just a setting which is turned off:

Tools > Options > Text Editors > C# > Advanced > Outlining > "Collapse #regions when collapsing to definitions"
 

0 Comments
This is the cleanest way to check a string for a number. I was looking for a nice way to do this and I came across this one:

        public bool IsNumeric(string text)
        {
            int n;
            return int.TryParse(text, out n);
        }

Really nice and clean solution!

0 Comments
This is a cool function to create a csv string from a generic list in C#:

public static string CreateCSVFromGenericList<T>(List<T> list)
        {
            if (list == null || list.Count == 0) return "";

            //get type from 0th member
            Type t = list[0].GetType();
            string newLine = Environment.NewLine;

            var sw = new StringBuilder();

             //make a new instance of the class name we figured out to get its props
            object o = Activator.CreateInstance(t);
            //gets all properties
            PropertyInfo[] props = o.GetType().GetProperties();

            //foreach of the properties in class above, write out properties
            //this is the header row
            sw.AppendLine(string.Join(",", props.Select(d => d.Name).ToArray()));

            //this acts as datarow
            foreach (T item in list)
            {
                //this acts as datacolumn
                var row = string.Join(",", props.Select(d => item.GetType()
                                                                .GetProperty(d.Name)
                                                                .GetValue(item, null)
                                                                .ToString())
                                                        .ToArray());
                sw.AppendLine(row);

            }
            return sw.ToString();
        }

0 Comments
'It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS'

When you get this error during building your web application in Visual Studio and you already tried to do these two solutions:
- Set you directory as an application in IIS
- When you have nested web.config files.  Remove or rename the one in a folder below or above your application directory.

You can try the following:
- Remove the obj folder in your sources directory and rebuilt the solution again.