Posts

Showing posts with the label C#

Decimal number issue from server to client. Wow! Didn't expect this @_@

Image
Chapter 17   where poor Decimal Number came from Server Side to JavaScript I worked on some page for days to adjust UI by CSS and HTML changes. It was pretty OK and fine. Until I started to check this page for multi-lingual support... It was good for English, Spanish and Chinese. And even right-to-left Hebrew! Crooked and askew but working! But not in Russian, no! In Russian it stopped working at all - nothing except static texts and images wasn't appeared. And of course it was an error in JS :-\ (FireFox DevTools): that led me strangely to somewhere to this code: I was staring on this rows and saw nothing wrong there - no missing variables at all. I went to original code in the project to discover the non-rendered rows and saw server variable there: that led me to server side C#: Nothing wrong at all. Here and there - another 10-15 minutes wasted to dumbly running the page again and again and stupidly staring on all these rows in different windows... :-\ Sad... Un...

Remove items from list that appears in another list by ID

I tried many options and stopped on this one: lst1.RemoveAll(itemFromLst1 => lst2.Any(itemFromLst2 => itemFromLst2.ID == itemFromLst1.ID));

Pluralizing words in C#.Net

Today I wanted to create a dynamic title of a page according to name of category. Like "My Playlists", "My Libraries" etc. So there is a parameter of categoryID passing to page and I find category object accordingly. So there is a usage of .Net service: using System.Data.Entity.Design.PluralizationServices; .... Category category = Category.GetByID(categoryID); PluralizationService ps = PluralizationService.CreateService( new System.Globalization.CultureInfo( "en-GB" )); Page.Title = $"My { ps.Pluralize( category .Name) }" ; ..... Note : you need to add reference System.Data.Entity.Design to the project.