Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have decimal values in the database. I want to show the decimal value in it. How to convert decimal values into it.
int vatprice;
dt.Load(cmd.ExecuteReader());
vatprice = Convert.ToInt32(dt.Rows[0][5].ToString());//getting error here
As per your requirement, round decimal up to 2 place using following way :
1) Use Math.Round().
var vatprice= Convert.ToDecimal(Math.Round(dt.Rows[0][5], 2));
2) second way is
var vatprice=Convert.ToDecimal(dt.Rows[0][5].ToString ("#.##"));
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to C#.
I have a method that returns an object with the List of objects inside.
0 {{DapperRow, RecordedFormID = 'id1'}} object {Dapper.SqlMapper.DapperRow}
1 {{DapperRow, RecordedFormID = 'id2'}} object {Dapper.SqlMapper.DapperRow}
How can I get those ids as strings?
Here is a screenshot
You can use System.Linq namespace and do this:
yourObject.Select(x => x.RecordedFormID);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to generate number as format above and I try to use UUID() and GUID() but it is not what I want(difference format and it is hexadecimal not number)
anyone have any idea or logic to do it?
The simplest way to generate 1000000000000 unique numbers is just an ever-increasing sequence:
long i = 42; // whatever
string key = $"{i / 100000000:0000}-{(i / 10000) % 10000:0000}-{i % 10000:0000}";
The next time, increase i before generating the key.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am updating the values in grid view. if i am updating the noofdays it will showing Input string was not in a correct and how to give me some suggestion.
and i have other question when the employee apply leave before week it will take the data else it will show the message.
how to write it logic.
code behind
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
ASPX
<asp:BoundField DataField="NoOfDays" HeaderText="Leave Period"></asp:BoundField>
Try this
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text) == NULL ? 0 :Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
Try it
please check the value is integer before convert the values.
Use string.IsNullOrEmpty
leaveUpdateRow.NoOfDays=string.IsNullOrEmpty(((TextBox)(row.Cells[4].Controls[0])).Text)?0:Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a string "5-13-2013"
I want to make it look like "051313"
All three fields (month,day,year) must have 2 digits, if it only has one , I need to add a zero in front
any easy way to do this?
You can convert your datetime to multiple formats like
string date = yourdateTime.ToString("dd/mm/yyyy");
string date = yourdateTime.ToString("dd/mm/yyyy HH:mm");
string date = yourdateTime.ToString("dd/mm/yyyy HH:mm:ss");
string date = yourdateTime.ToString("mmddyy"); // your desired
To know what these mean you need to read here.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to reduce the number of figures of a number?
Example:
double d = 222222222222222224444444444444.0
I want to "serialize" it like 17[2]13[4] for example.
The idea is to reduce the number of "chars" used by the number.
double d = 222222222222222224444444444444.0
You can't have a double that big in the first place.
I want to "serialize" it like 17[2]13[4] for example.
The idea is to reduce the number of "chars" used by the number.
A double only takes 8 bytes regardless of its value. There doesn't seem to be any actual point to this.