TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankit Sahu
580
2k
893.8k
Get Anonymous Object using C#
Nov 13 2018 4:48 AM
class
Program
{
static
void
Main(
string
[] args)
{
List<AssignedUsers> assUser =
new
List<AssignedUsers>() {
new
AssignedUsers(){Id=1,name=
"Lao Lao"
,parent=0},
new
AssignedUsers(){Id=2,name=
"Bo Miao"
,parent=1},
new
AssignedUsers(){Id=3,name=
"Li Xin"
,parent=2},
new
AssignedUsers(){Id=4,name=
"Su Miao"
,parent=1},
new
AssignedUsers(){Id=5,name=
"Pang Pang"
,parent=6},
new
AssignedUsers(){Id=6,name=
"Dan Dan"
,parent=6},
new
AssignedUsers(){Id=7,name=
"Hong Miao"
,parent=1}
};
}
public
class
AssignedUsers
{
public
int
Id {
get
;
set
; }
public
string
name {
get
;
set
; }
public
int
parent {
get
;
set
; }
public
string
titlenew {
get
;
set
; }
}
}
How to get below object :
{
"id": "1",
"name": "Lao Lao",
"titlenew": "general manager",
"children": [
{
"id": "2",
"name": "Bo Miao",
"titlenew": "department manager",
"parentId": "1",
"children": [
{
"id": "3",
"name": "Li Xin",
"titlenew": "senior engineer",
"parentId": "2"
}
]
},
{
"id": "4",
"name": "Su Miao",
"titlenew": "department manager",
"children": [
{
"id": "5",
"name": "Tie Hua",
"titlenew": "senior engineer",
"parentId": "4"
},
{
"id": "6",
"name": "Hei Hei",
"titlenew": "senior engineer",
"children": [
{
"id": "7",
"name": "
Pang Pang
",
"titlenew": "engineer",
"parentId": "6"
},
{
"id": "8",
"name": "
Dan Dan
",
"titlenew": "UE engineer",
"parentId": "6"
}
],
"parentId": "4"
}
],
"parentId": "1"
},
{
"id": "9",
"name": "Hong Miao",
"parentId": "1"
}
]
}
Reply
Answers (
3
)
How to arrange two combined columns of DataGridView?
Oledb Data reader/Adapter is failing to read bulk data