This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 1 */ | |
| { | |
| "_id": ObjectId("5762a62714f0511a442eb3f1"), | |
| "student": ObjectId("572a529051e56dd889ff93f1"), | |
| "type" : "Homework", | |
| "score" : 2 | |
| } | |
| /* 2 */ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 1 */ | |
| { | |
| "_id" : ObjectId("572a529051e56dd889ff93f1"), | |
| "name" : "Bob" | |
| } | |
| /* 2 */ | |
| { | |
| "_id" : ObjectId("5734d3569f2eb3b0319b5370"), | |
| "name" : "John" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .method public hidebysig static | |
| void Main () cil managed | |
| { | |
| // Method begins at RVA 0x216c | |
| // Code size 52 (0x34) | |
| .maxstack 3 | |
| .entrypoint | |
| .locals init ( | |
| [0] class '<>f__AnonymousType0`2'<string, int32> anonymousType | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void Main() | |
| { | |
| var anonymousType = new {Autor = "João Bateloche", Dia = 19}; | |
| //Cole no Visual Studio e coloque o mouse sobre as propriedades | |
| //O tipo é estático, não será possível atribuir um tipo diferente | |
| // para as propiedades | |
| Console.WriteLine(anonymousType.Autor + " " + anonymousType.Dia); | |
| Console.ReadKey(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void Main() | |
| { | |
| dynamic teste = new ExpandoObject(); | |
| teste.Tipo = "Dinâmico"; | |
| teste.Ola = new Action<string>((x) => { Console.WriteLine("Olá " + x); }); | |
| teste.Ola("Leitor"); | |
| Console.WriteLine(teste.Tipo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .method public hidebysig static void Main() cil managed | |
| { | |
| .entrypoint | |
| // Code size 31 (0x1f) | |
| .maxstack 1 | |
| .locals init ([0] string tipadaImplicitamente, | |
| [1] string tipadaExplicitamente) | |
| IL_0000: ldstr "Exemplo1" | |
| IL_0005: stloc.0 | |
| IL_0006: ldstr "Exemplo2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void Main() | |
| { | |
| var tipadaImplicitamente = "Exemplo1"; | |
| string tipadaExplicitamente = "Exemplo2"; | |
| Console.WriteLine(tipadaImplicitamente); | |
| Console.WriteLine(tipadaExplicitamente); | |
| Console.ReadKey(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct/class MyObject | |
| { | |
| public string Valor { get; set; } | |
| } | |
| class Program | |
| { | |
| public static void Main() | |
| { | |
| var objeto = new MyObject(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.students.aggregate([{ | |
| $project:{ | |
| _id: false, | |
| name:'$name', | |
| finalScore: { | |
| $sum: '$scores.score' | |
| } | |
| } | |
| }]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.students.aggregate([{ | |
| $unwind: "$scores" | |
| },{ | |
| $group: { | |
| _id: "$name", | |
| score: { $sum: "$scores.score" } | |
| } | |
| },{ | |
| $project:{ | |
| _id: false, |