这是我在“名称”字段中搜索值的代码,现在我想要列表中包含任何字段值的所有项目(可能是 id 或名称)
List<dynamic> list = new List<dynamic>();
for(int i=0;i<10;i++)
{
dynamic expando = new ExpandoObject();
var p = expando as IDictionary<String, object>;
((IDictionary<string, object>)expando)["Id"] = (i % 2)*10;
((IDictionary<string, object>)expando)["name"] = (i).ToString();
list.Add(expando);
}
var value = list.FindAll(x =>
{
var dic = x as IDictionary<string, object>;
return
dic["name"].ToString().Contains("value");
});
Run Code Online (Sandbox Code Playgroud)
任何帮助将是非常可观的。
我已经浏览了一天关于如何从excel文件中插入documentDB中的批量数据,但我没有得到任何信息.
我可以从excel文件中读取数据并在documentDB中逐个插入
Service service = new Service();
foreach(data in exceldata) //exceldata contains set of rows
{
var student = new Student();
student.id= "";
student.name = data.name;
student.age = data.age;
student.class = data.class;
student.id = service.savetoDocumentDB(collectionLink,student); //collectionlink is a string stored in web.config
students.add(student);
}
Class Service
{
public async Task<string> AddDocument(string collectionLink, Student data)
{
this.DeserializePayload(data);
var result = await Client.CreateDocumentAsync(collectionLink, data);
return result.Resource.Id;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以在一个实例中插入所有记录吗?
任何帮助都会非常明显.
我有一个学生的对象
Class Student
{
public Student()
{
name = "xyz";
roll = 20;
age = 16;
}
string name;
int roll;
int age;
}
Class Service
{
Student student = new Student();
string s = ???
// what I have to do for getting string like {"name" : "xyz", "roll" : 20, "age" :16}
}
Run Code Online (Sandbox Code Playgroud)
我需要来自上面对象的字符串.
如果我序列化对象我得到的东西与转义序列.
任何帮助都会非常明显.
我想以左对齐水平反向显示项目
这是我的工作小提琴,但项目右对齐。
#main {
width: 400px;
height: 400px;
border: 1px solid #c3c3c3;
display: flex;
flex-direction: row-reverse;
align-items: flex-start;
}
#main div {
width: 50px;
height: 50px;
}Run Code Online (Sandbox Code Playgroud)
<div id="main">
<div style="background-color:coral;">A</div>
<div style="background-color:lightblue;">B</div>
<div style="background-color:khaki;">C</div>
<div style="background-color:pink;">D</div>
<div style="background-color:lightgrey;">E</div>
<div style="background-color:lightgreen;">F</div>
</div>Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗,谢谢。
假设我有一个List动态对象,如:
var records = [
{
"Id": 1,
"Name": "sai",
"Age": "4",
"About": "12.02.1991"
},
{
"Id": 2,
"Name": "hjfh",
"Age": "2",
"About": "12.02.1991"
},
{
"Id": 3,
"Name": "hello name",
"Age": "6",
"About": "hi"
},
{
"Id": 4,
"Name": 1,
"Age": "9",
"About": "hello world"
}
]
string searchString = "Hello";
Run Code Online (Sandbox Code Playgroud)
我尝试过类似的东西:
foreach (var item in records )
{
foreach (var field in item)
{
if (field.Value != null && field.Value.ToString().IndexOf(query.SearchString, StringComparison.OrdinalIgnoreCase) >= 0)
{
count++;
break; …Run Code Online (Sandbox Code Playgroud) 我有一个像json对象
{ "name" : "sai", "age" : 22, "salary" : 25000}
Run Code Online (Sandbox Code Playgroud)
我想通过更新JSON对象
`{ "name" : "sai", "age" : 23, "Gender" : "male"}`
Run Code Online (Sandbox Code Playgroud)
然后我想要类似的结果
{ "name" : "sai", "age" : 23, "salary" : 25000, "Gender" : "male"}
Run Code Online (Sandbox Code Playgroud)
我尝试了类似的东西
foreach(var item in actualJson)
{
bool isFound = false;
foreach(var newItem in newJson)
{
if(item == newItem) // always returns false, anything wrong with this?
{
isFound = true;
break;
}
}
if(!isFound)
{
// add to json
}
}
Run Code Online (Sandbox Code Playgroud)
我没有任何想法来解决这个问题?
任何帮助/指导将不胜感激。