Converting integers to roman numerals

Try this, simple and compact: public static string ToRoman(int number) { if ((number < 0) || (number > 3999)) throw new ArgumentOutOfRangeException(“insert value betwheen 1 and 3999”); if (number < 1) return string.Empty; if (number >= 1000) return “M” + ToRoman(number – 1000); if (number >= 900) return “CM” + ToRoman(number – 900); if (number … Read more

LINQ – selecting second item in IEnumerable

While what you have works, the most straightforward way would be to use the array’s index and reference the second item (at index 1 since the index starts at zero for the first element): pkgratio[1] Console.WriteLine(pkgratio[1]); A more complete example: string[] pkgratio = “1:2:6”.Split(‘:’); for (int i = 0; i < pkgratio.Length; i++) Console.WriteLine(pkgratio[i]); With … Read more

Func delegate with ref variable

It cannot be done by Func but you can define a custom delegate for it: public delegate object MethodNameDelegate(ref float y); Usage example: public object MethodWithRefFloat(ref float y) { return null; } public void MethodCallThroughDelegate() { MethodNameDelegate myDelegate = MethodWithRefFloat; float y = 0; myDelegate(ref y); }

how to insert datetime into the SQL Database table?

DateTime values should be inserted as if they are strings surrounded by single quotes: ‘20100301’ SQL Server allows for many accepted date formats and it should be the case that most development libraries provide a series of classes or functions to insert datetime values properly. However, if you are doing it manually, it is important … Read more

Why does the Equals implementation for anonymous types compare fields?

Anonymous type instances are immutable data values without behavior or identity. It doesn’t make much sense to reference-compare them. In that context I think it is entirely reasonable to generate structural equality comparisons for them. If you want to switch the comparison behavior to something custom (reference comparison or case-insensitivity) you can use Resharper to … Read more

Generic List as parameter on method

To take a generic List<T> vs a bound List<int> you need to make the method generic as well. This is done by adding a generic parameter to the method much in the way you add it to a type. Try the following void Export<T>(List<T> data, params string[] parameters) { … }

How to iterate through Dictionary and change values?

According to MSDN: The foreach statement is a wrapper around the enumerator, which allows only reading from the collection, not writing to it. Use this: var dictionary = new Dictionary<string, double>(); // TODO Populate your dictionary here var keys = new List<string>(dictionary.Keys); foreach (string key in keys) { dictionary[key] = Math.Round(dictionary[key], 3); }

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