Join collection of objects into comma-separated string
string.Join(“, “, Array.ConvertAll(somelist.ToArray(), i => i.ToString()))
string.Join(“, “, Array.ConvertAll(somelist.ToArray(), i => i.ToString()))
You can create a new instance of date with the seconds set to 0. DateTime a = DateTime.UtcNow; DateTime b = new DateTime(a.Year, a.Month, a.Day, a.Hour, a.Minute, 0, a.Kind); Console.WriteLine(a); Console.WriteLine(b);
void Foo() { throw new OutOfMemoryException(); } :)))
Using C# (.net 4.0) with SQLite, the SQLiteConnection class has a property LastInsertRowId that equals the Primary Integer Key of the most recently inserted (or updated) element. The rowID is returned if the table doesn’t have a primary integer key (in this case the rowID is column is automatically created). See https://www.sqlite.org/c3ref/last_insert_rowid.html for more. As … Read more
Deadlock in System.Component.TypeDescriptor [closed]
I have not been able to use the loggerFactory.AddEventLog() in .Net Core 2.0. As the Microsoft.Extensions.Logger.EventLog only lives in .net 4.5.1 although the Nuget package is available for 2.0.0 here , so looks like it needs to be ported to Core. but maybe this will work for you. Add your CustomEventIds public static class CustomEventIds … Read more
If you want a simple design, essentially I would do it in a static mapper class. We definitely need more information to help you, but short of that, here is some psuedocode (not production code) that should be a sufficient design pattern. public static class CustomMapper { public static void leadToContact(Lead lead, ID contactID) { … Read more
Microsoft Connect Discussion Here is some code to workaround: static int CompareStringUsingSortKey(string s1, string s2) { SortKey sk1 = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(s1); SortKey sk2 = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(s2); return SortKey.Compare(sk1, sk2); }
Every time you navigate to a Page, you create a new instance of Page, but the previous Page is not disposed (even if the Page is already in the navigation stack). To prevent multiple allocation of same page, set NavigationCacheMode=”Enabled” attribute to the Page. Also, to minimize the memory allocation, you must override method OnNavigatedTo … Read more
If the PDF which you are trying is a template/predefined/fixed then you can remove that object by calling RemoveField. PdfReader pdfReader = new PdfReader(../Template_Path.pdf”)); PdfStamper pdfStamperToPopulate = new PdfStamper(pdfReader, new FileStream(outputPath, FileMode.Create)); AcroFields pdfFormFields = pdfStamperToPopulate.AcroFields; pdfFormFields.RemoveField(“fieldNameToBeRemoved”);