What’s the @ in front of a string in C#?

It marks the string as a verbatim string literal – anything in the string that would normally be interpreted as an escape sequence is ignored. So “C:\\Users\\Rich” is the same as @”C:\Users\Rich” There is one exception: an escape sequence is needed for the double quote. To escape a double quote, you need to put two double quotes in a row. For instance, @”””” evaluates … Read more

ArrayList vs List<> in C#

Yes, pretty much. List<T> is a generic class. It supports storing values of a specific type without casting to or from object (which would have incurred boxing/unboxing overhead when T is a value type in the ArrayList case). ArrayList simply stores object references. As a generic collection, List<T> implements the generic IEnumerable<T> interface and can be used easily in LINQ (without requiring any Cast or OfType call). ArrayList belongs to the days that C# didn’t have … Read more

Cannot access a disposed object – How to fix?

Try checking the IsDisposed property before accessing the control. You can also check it on the FormClosing event, assuming you’re using the FormClosed event. We do stop the Timer on the FormClosing event and we do check the IsDisposed property on the schedule component before using it in the Timer Tick event but it doesn’t help. Calling GC.Collect before … Read more

HashSet vs. List performance

A lot of people are saying that once you get to the size where speed is actually a concern that HashSet<T> will always beat List<T>, but that depends on what you are doing. Let’s say you have a List<T> that will only ever have on average 5 items in it. Over a large number of cycles, if a single item … Read more

Cannot access a disposed object – How to fix?

Try checking the IsDisposed property before accessing the control. You can also check it on the FormClosing event, assuming you’re using the FormClosed event. We do stop the Timer on the FormClosing event and we do check the IsDisposed property on the schedule component before using it in the Timer Tick event but it doesn’t help. Calling GC.Collect before … Read more

Pass Method as Parameter using C#

You can use the Func delegate in .net 3.5 as the parameter in your RunTheMethod method. The Func delegate allows you to specify a method that takes a number of parameters of a specific type and returns a single argument of a specific type. Here is an example that should work:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)