Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Trials
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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; using System.Linq; namespace Rextester { public class ids{ public string name; public string id; } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); List<ids> collectionofids = new List<ids>(); var id = new ids(); id.name = "nandhini"; id.id = "1"; collectionofids.Add(id); var ids = new ids(); ids.name = "priya"; ids.id = "1"; collectionofids.Add(ids); var dict = collectionofids.Aggregate(new Dictionary<string,List<ids>>(),(p,c)=>{ if(p.ContainsKey(c.id)){ p[c.id].Add(c); } else{ p[c.id] = new List<ids>(){id}; } return p; }); int i=1; foreach(var a in dict){ Console.WriteLine(i++); Console.Write("=>key:"+a.Key); var c = dict[a.Key]; Console.Write("Value:"); foreach(var b in c) { Console.Write(b.name,","); } } } } }
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion
stackse - search stackoverflow differently