33
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
6
public class Program
7
{
8
public static void Main()
9
{
10
string[] words =
11
{
12
"hello", "wonderful", "linq", "beautiful", "world"
13
};
14
15
// Query Syntax
16
var shortWords1 = from w in words
17
where w.Length <= 5
18
select w;
19
20
// Method Syntax
21
var shortWords2 = words.Where(x=>x.Length <= 5);
22
23
24
Console.WriteLine("ShortWords1: {0}", shortWords1.Count());
25
Console.WriteLine("ShortWords2: {0}", shortWords2.Count());
26
Console.WriteLine();
27
28
foreach(var item in shortWords2)
29
{
30
Console.WriteLine(item);
31
}
32
}
33
}
Cached Result
----- Original JSON ---
{
"FirstObject": {
"NestedObject": {
"AttributeString": "ok",
"AttributeNumeric": 123.45
},
"OtherObject": [
{
"ArrayVal": 100
},
{
"ArrayVal": 200
}
]
}
}
----- Converted to snake_case ---
{
"first_object": {
"nested_object": {
"attribute_string": "ok",
"attribute_numeric": "123.45"
},
"other_object": [
{
"array_val": "100"
},
{
"array_val": "200"
}
]
}
}
----- Converted back to UpperCamelCase ---
{
"FirstObject": {
"NestedObject": {
"AttributeString": "ok",
"AttributeNumeric": "123.45"
},
"OtherObject": [
{
"ArrayVal": "100"
},
{
"ArrayVal": "200"
}
]
}
}
{
"FirstObject": {
"NestedObject": {
"AttributeString": "ok",
"AttributeNumeric": 123.45
},
"OtherObject": [
{
"ArrayVal": 100
},
{
"ArrayVal": 200
}
]
}
}
----- Converted to snake_case ---
{
"first_object": {
"nested_object": {
"attribute_string": "ok",
"attribute_numeric": "123.45"
},
"other_object": [
{
"array_val": "100"
},
{
"array_val": "200"
}
]
}
}
----- Converted back to UpperCamelCase ---
{
"FirstObject": {
"NestedObject": {
"AttributeString": "ok",
"AttributeNumeric": "123.45"
},
"OtherObject": [
{
"ArrayVal": "100"
},
{
"ArrayVal": "200"
}
]
}
}