Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
LINQ-Group BY
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Account[] accounts = { new Account("Tom", "Smith", "132CK", 100.23), new Account("Tom", "Krammer", "132CD", 10000.00), new Account("Ralph", "Smith", "436CD", 1923.85), new Account("Ralph", "Jones", "454MM", 987.132), new Account("Ted", "Krammer", "897CD", 3223.19), new Account("Ralph", "Jones", "434CK", -123.32), new Account("Sara", "Smith", "543MM", 5017.40), new Account("Sara", "Krammer", "547CD", 34955.79), new Account("Sara", "Jones", "843CK", 345.00), new Account("Albert", "Smith", "445CK", 213.67), new Account("Betty", "Krammer","968MM",5146.67), new Account("Carl", "Smith", "078CD", 15345.99), new Account("Jenny", "Jones", "108CK", 10.98) }; var accInfo = from acc in accounts orderby acc.firstName group acc by acc.firstName; foreach(var grpAcc in accInfo){ Console.WriteLine("Grouped by firstName: "+grpAcc.Key); foreach(var acc in grpAcc){ Console.WriteLine(" "+acc.firstName+" "+acc.lastName+" --> "+acc.balance); } Console.WriteLine(); } } } public class Account{ public string firstName{get;private set;} public string lastName{get;private set;} public string accNum{get;private set;} public double balance{get;private set;} public Account(string firstName, string lastName, string accNum, double balance){ this.firstName = firstName; this.lastName = lastName; this.accNum = accNum; this.balance = balance; } } }
run
|
edit
|
history
|
help
1
GEFCSADX
line 1 syntax error
simultQ
Array 10th grade
Jahongirochilov270@gmail.com
john
Returning the number of 1s in the binary representation of an unsigned integer
float to short cast overflow
Gamez
D110