Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: Integers to Float IEEE 754 Pin
Member 148721281-Jul-20 8:09
Member 148721281-Jul-20 8:09 
GeneralRe: Integers to Float IEEE 754 Pin
Luc Pattyn1-Jul-20 9:29
sitebuilderLuc Pattyn1-Jul-20 9:29 
QuestionHow can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 11:14
arnold_w30-Jun-20 11:14 
AnswerRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:18
mveDave Kreskowiak30-Jun-20 11:18 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 11:36
arnold_w30-Jun-20 11:36 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:59
mveDave Kreskowiak30-Jun-20 11:59 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn30-Jun-20 11:48
sitebuilderLuc Pattyn30-Jun-20 11:48 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:59
mveDave Kreskowiak30-Jun-20 11:59 
AnswerRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn30-Jun-20 12:35
sitebuilderLuc Pattyn30-Jun-20 12:35 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 19:52
arnold_w30-Jun-20 19:52 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
kalberts1-Jul-20 0:09
kalberts1-Jul-20 0:09 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w1-Jul-20 0:15
arnold_w1-Jul-20 0:15 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn1-Jul-20 1:08
sitebuilderLuc Pattyn1-Jul-20 1:08 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w1-Jul-20 1:58
arnold_w1-Jul-20 1:58 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn1-Jul-20 2:08
sitebuilderLuc Pattyn1-Jul-20 2:08 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w1-Jul-20 2:12
arnold_w1-Jul-20 2:12 
QuestionVS2017 publish project to .exe without manifest files Pin
Member 1487747430-Jun-20 10:35
Member 1487747430-Jun-20 10:35 
AnswerRe: VS2017 publish project to .exe without manifest files Pin
Dave Kreskowiak30-Jun-20 11:15
mveDave Kreskowiak30-Jun-20 11:15 
QuestionOptimize Linq To SQL Query Pin
Kevin Marois30-Jun-20 8:21
professionalKevin Marois30-Jun-20 8:21 
QuestionC# Pin
Member 1258896327-Jun-20 5:30
Member 1258896327-Jun-20 5:30 
AnswerRe: C# Generate a password dictionary to log into API Pin
OriginalGriff27-Jun-20 5:49
mveOriginalGriff27-Jun-20 5:49 
GeneralRe: C# Generate a password dictionary to log into API Pin
Member 1258896327-Jun-20 5:59
Member 1258896327-Jun-20 5:59 
GeneralRe: C# Generate a password dictionary to log into API Pin
OriginalGriff27-Jun-20 6:00
mveOriginalGriff27-Jun-20 6:00 
GeneralRe: C# Generate a password dictionary to log into API Pin
Dave Kreskowiak27-Jun-20 7:10
mveDave Kreskowiak27-Jun-20 7:10 
QuestionBest way to transform list and get top result from custom sort order? Pin
linalinea26-Jun-20 9:44
linalinea26-Jun-20 9:44 
Hi!

I am trying to find the best way to transform a list of objects and sort based on custom order:

I have a list of profile duplicates, and need to find "top" profile based on a priority order. The top profile need to be transformed into a new object with 3 properties. These 3 properties also dictate the sort order.

The 3 new enum-based properties are:

ProfileType with types (SuperUser > NormalUser > Beginner),
ProfileSubType with types (Internal > External),
ProfileValidity with types (Valid > ValidInFuture > Expire)

The properties are based on enums from an external source and are out of order, so I need to have my own custom sort for each of them.

So e.g. a prioritized list would look like:

{Superuser, Internal, Valid},
{Superuser, Internal, Expired},
{Superuser, External, Valid},
{Normaluser, Internal, Valid},
{Beginner, Internal, Expire}

Right now my solution is this:

C#
TransformedProfile = profileList.Select(x => new TransformedProfile
    {
    ProfileType = GetProfileType(x.PropertyA),
    ProfileSubType = GetProfileSubType(x.PropertyB),
    ProfileValidity = GetValidity(x.StartDate, x.ExpiryDate)
    })
    .OrderBy(y => typePriorityDict[y.ProfileType])
    .ThenBy(y => subTypePriorityDict[y.ProfileSubType])
    .ThenBy(y => validityPriorityDict[y.ProfileValidity])
    .FirstOrDefault();


The typePriorityDict, subTypePriorityDict, validityPriorityDict are dictionaries with my custom sort order.

This solution works ok and gives me the desired result. But I was wondering if there are more efficient ways of doing this?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.