Skip to main content
added 57 characters in body
Source Link
sehe
  • 400.3k
  • 49
  • 475
  • 673

I have a list of object that has two properties, let's say a and b. a is an Enum like:

first=1[Flags] enum MyEnum { first = 1,  second = 2,  third  = 4, forth  fourth = 8,... }; 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer, which is a mask (combination of the MyEnum flags).

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

I'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in Linq

EDIT: I think i wasn't clear. i want to sum the object by the Enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 

I have a list of object that has two properties, let's say a and b. a is an Enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

I'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in Linq

EDIT: I think i wasn't clear. i want to sum the object by the Enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 

I have a list of object that has two properties, let's say a and b. a is an Enum like:

[Flags] enum MyEnum { first = 1,  second = 2,  third  = 4,   fourth = 8 }; 

b is an unsigned integer, which is a mask (combination of the MyEnum flags).

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

I'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in Linq

EDIT: I think i wasn't clear. i want to sum the object by the Enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 
spelling and formatting Grammer
Source Link

iI have a list of object that has two properties, let's say a and b. a is an enumEnum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

i'mI'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in linqLinq

EDIT: I think i wasn't clear. i want to sum the object by the enumEnum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 

i have a list of object that has two properties, let's say a and b. a is an enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

i'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in linq

EDIT: I think i wasn't clear. i want to sum the object by the enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 

I have a list of object that has two properties, let's say a and b. a is an Enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

I'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in Linq

EDIT: I think i wasn't clear. i want to sum the object by the Enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 
added 236 characters in body
Source Link
No Idea For Name
  • 11.6k
  • 11
  • 49
  • 73

i have a list of object that has two properties, let's say a and b. a is an enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

i'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in linq

EDIT: I think i wasn't clear. i want to sum the object by the enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 

i have a list of object that has two properties, let's say a and b. a is an enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

i'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in linq

i have a list of object that has two properties, let's say a and b. a is an enum like:

first=1, second = 2, third = 4, forth = 8,... 

I don't know how is it called in english... if anyone can edit that it would be great. b is an unsigned integer.

now i need to sum every object by their a - meaning an object can be summed twice if obj.a = first | third and i can't seem to do a groupBy to them. is there a different way to sum them?

i'm sorry i don't share my code, but i can't. i can tell you i did it using foreach in just some if - else blocks but i think i should learn how to do it in linq

EDIT: I think i wasn't clear. i want to sum the object by the enum, meaning if i have:

obj1.a = first, obj1.b = 5 obj2.a = first | second, obj2.b = 3 

then the output will be

first sum = 8 second sum = 3 
Source Link
No Idea For Name
  • 11.6k
  • 11
  • 49
  • 73
Loading