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
Ashok
NA
507
80.4k
How to convert Decimal to integer
Jan 6 2021 12:27 PM
Hi All,
As I am converting the below JSON from dataset, in the backend oracle it is number datatype.
so due this in the json I am getting like decimal value. How to avoid this
that not to get like decimal value.
{
"max_no": 899.0,
"total": 10200.0,
"no": 123456789.0
}
Class file
public
class
root
{
public
decimal
max_no {
get
;
set
; }
public
double
total {
get
;
set
; }
public
decimal
no {
get
;
set
; }
}
C# code
var JsonList = ds.Tables[0].AsEnumerable().Select(dataRow =>
new
root()
{
max_no =dataRow.Field<
decimal
>(
"max_no"
),
total = dataRow.Field<
double
>(
"total"
),
no = dataRow.Field<
decimal
>(
"no"
)
}).ToList();
return
Request.CreateResponse(HttpStatusCode.OK, JsonList);
how to get the JSON as below
{
"max_no": 899,
"total": 10200,
"no": 123456789
}
Reply
Answers (
2
)
How to convert dataset result to class object
Structural Design patterns in C#