[.Net] [solved] System.ArgumentNullException: Value cannot be null. (Parameter ‘key’)

This exception literally made me go mad, The stack-trace was such a trash for this, that I had to go debugging line by line, anyway, for me and for anyone else I'm posting the solution, which might be the case also for you, I'm also posting the not so useful stacktrace at the end of … Continue reading [.Net] [solved] System.ArgumentNullException: Value cannot be null. (Parameter ‘key’)

[C#]Convert List/Enumerable to DataTable

public static DataTable ToDataTable<T>(this IEnumerable<T> iEnumerable) { if(iEnumerable is null) throw new ArgumentNullException(nameof(iEnumerable), "Enumerable is null"); var dataTable = new DataTable(); var propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(T)); foreach (PropertyDescriptor propertyDescriptor in propertyDescriptorCollection) { var type = propertyDescriptor.PropertyType; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) type = Nullable.GetUnderlyingType(type); dataTable.Columns.Add(propertyDescriptor.DisplayName, type!); } var values = new object[propertyDescriptorCollection.Count]; foreach (var iListItem … Continue reading [C#]Convert List/Enumerable to DataTable

[How-To][C#]Dynamically adding MenuItem and using Binding with viewModel

WPF's databinding is a powerful feature and I love how easy it becomes once you start to learn. so in my journey of MVVM, I had the requirement to use a WPF Menu Control, where I created Menu in XAML and then binded their commands via ViewModel, but I was Curious as if there was … Continue reading [How-To][C#]Dynamically adding MenuItem and using Binding with viewModel