Skip to content

Instantly share code, notes, and snippets.

View bateloche's full-sized avatar

João Bateloche bateloche

View GitHub Profile
/* 1 */
{
"_id": ObjectId("5762a62714f0511a442eb3f1"),
"student": ObjectId("572a529051e56dd889ff93f1"),
"type" : "Homework",
"score" : 2
}
/* 2 */
{
/* 1 */
{
"_id" : ObjectId("572a529051e56dd889ff93f1"),
"name" : "Bob"
}
/* 2 */
{
"_id" : ObjectId("5734d3569f2eb3b0319b5370"),
"name" : "John"
.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
)
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();
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);
.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"
public static void Main()
{
var tipadaImplicitamente = "Exemplo1";
string tipadaExplicitamente = "Exemplo2";
Console.WriteLine(tipadaImplicitamente);
Console.WriteLine(tipadaExplicitamente);
Console.ReadKey();
}
public struct/class MyObject
{
public string Valor { get; set; }
}
class Program
{
public static void Main()
{
var objeto = new MyObject();
db.students.aggregate([{
$project:{
_id: false,
name:'$name',
finalScore: {
$sum: '$scores.score'
}
}
}])
db.students.aggregate([{
$unwind: "$scores"
},{
$group: {
_id: "$name",
score: { $sum: "$scores.score" }
}
},{
$project:{
_id: false,