How to Convert TextBox string with decimal to decimal in c# Windows form.
I have column in my database with decimal(18, 0) Data type.
When I try to insert then I get "Wrong format". I do like this...:
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text);
Letsay if I write 25.89 then this givs me error message "wrong format"
It's working with hole numbers, like 25 but not with dot 25.89
I use this eventHandler on Textbox:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if(ch == 46 && txtAmountToTransfer.Text.IndexOf('.') != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
It should be easy but I have tried with many methods but stil I dont get it to work. Thank you in advance
c# textbox decimal windows-forms-designer
add a comment |
I have column in my database with decimal(18, 0) Data type.
When I try to insert then I get "Wrong format". I do like this...:
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text);
Letsay if I write 25.89 then this givs me error message "wrong format"
It's working with hole numbers, like 25 but not with dot 25.89
I use this eventHandler on Textbox:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if(ch == 46 && txtAmountToTransfer.Text.IndexOf('.') != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
It should be easy but I have tried with many methods but stil I dont get it to work. Thank you in advance
c# textbox decimal windows-forms-designer
1
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
1
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
1
Well, if it is a user input, thendecimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma,
instead of dot.
will work.
– SeM
Nov 20 '18 at 8:18
How to detect current culture separator:char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27
add a comment |
I have column in my database with decimal(18, 0) Data type.
When I try to insert then I get "Wrong format". I do like this...:
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text);
Letsay if I write 25.89 then this givs me error message "wrong format"
It's working with hole numbers, like 25 but not with dot 25.89
I use this eventHandler on Textbox:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if(ch == 46 && txtAmountToTransfer.Text.IndexOf('.') != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
It should be easy but I have tried with many methods but stil I dont get it to work. Thank you in advance
c# textbox decimal windows-forms-designer
I have column in my database with decimal(18, 0) Data type.
When I try to insert then I get "Wrong format". I do like this...:
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text);
Letsay if I write 25.89 then this givs me error message "wrong format"
It's working with hole numbers, like 25 but not with dot 25.89
I use this eventHandler on Textbox:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if(ch == 46 && txtAmountToTransfer.Text.IndexOf('.') != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
It should be easy but I have tried with many methods but stil I dont get it to work. Thank you in advance
c# textbox decimal windows-forms-designer
c# textbox decimal windows-forms-designer
asked Nov 20 '18 at 8:14
Helen TekieHelen Tekie
140119
140119
1
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
1
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
1
Well, if it is a user input, thendecimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma,
instead of dot.
will work.
– SeM
Nov 20 '18 at 8:18
How to detect current culture separator:char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27
add a comment |
1
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
1
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
1
Well, if it is a user input, thendecimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma,
instead of dot.
will work.
– SeM
Nov 20 '18 at 8:18
How to detect current culture separator:char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27
1
1
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
1
1
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
1
1
Well, if it is a user input, then
decimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma ,
instead of dot .
will work.– SeM
Nov 20 '18 at 8:18
Well, if it is a user input, then
decimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma ,
instead of dot .
will work.– SeM
Nov 20 '18 at 8:18
How to detect current culture separator:
char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27
How to detect current culture separator:
char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27
add a comment |
2 Answers
2
active
oldest
votes
Try the following approach:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
char decimalSeparatorChar = Convert.ToChar(Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
if(ch == decimalSeparatorChar && txtAmountToTransfer.Text.IndexOf(decimalSeparatorChar) != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != decimalSeparatorChar)
{
e.Handled = true;
}
}
Then decimal.Parse(txtAmountToTransfer.Text)
will work fine. And make sure you are using correct decimal separator when you type in numbers.
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
add a comment |
Try using
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text, CultureInfo.InvariantCulture);
This is nice until,
is a decimal separator in your culture.
– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388749%2fhow-to-convert-textbox-string-with-decimal-to-decimal-in-c-sharp-windows-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try the following approach:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
char decimalSeparatorChar = Convert.ToChar(Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
if(ch == decimalSeparatorChar && txtAmountToTransfer.Text.IndexOf(decimalSeparatorChar) != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != decimalSeparatorChar)
{
e.Handled = true;
}
}
Then decimal.Parse(txtAmountToTransfer.Text)
will work fine. And make sure you are using correct decimal separator when you type in numbers.
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
add a comment |
Try the following approach:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
char decimalSeparatorChar = Convert.ToChar(Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
if(ch == decimalSeparatorChar && txtAmountToTransfer.Text.IndexOf(decimalSeparatorChar) != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != decimalSeparatorChar)
{
e.Handled = true;
}
}
Then decimal.Parse(txtAmountToTransfer.Text)
will work fine. And make sure you are using correct decimal separator when you type in numbers.
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
add a comment |
Try the following approach:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
char decimalSeparatorChar = Convert.ToChar(Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
if(ch == decimalSeparatorChar && txtAmountToTransfer.Text.IndexOf(decimalSeparatorChar) != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != decimalSeparatorChar)
{
e.Handled = true;
}
}
Then decimal.Parse(txtAmountToTransfer.Text)
will work fine. And make sure you are using correct decimal separator when you type in numbers.
Try the following approach:
private void txtAmountToTransfer_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
char decimalSeparatorChar = Convert.ToChar(Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
if(ch == decimalSeparatorChar && txtAmountToTransfer.Text.IndexOf(decimalSeparatorChar) != -1)
{
e.Handled = true;
return;
}
if(!Char.IsDigit(ch) && ch != 8 && ch != decimalSeparatorChar)
{
e.Handled = true;
}
}
Then decimal.Parse(txtAmountToTransfer.Text)
will work fine. And make sure you are using correct decimal separator when you type in numbers.
edited Nov 20 '18 at 8:39
answered Nov 20 '18 at 8:33
Access DeniedAccess Denied
5,12121643
5,12121643
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
add a comment |
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
Thank you it is working but if I put 25,50 then in database did not insert 25,50 but 26. It's rounding. Is any way t oget 25,50 ... or if I put 30,80 then I get the same value in my database. I'am trying to create banking system. If everybody deposit with 25,50 and my code rounding to 26, then this bank will lose a lot of Money.. (it's just an example) so I wonder if there is any way to get the same value as I put in my textbox. As I mention in my question it's decimal(18, 0) Data type. Thank you again.
– Helen Tekie
Nov 20 '18 at 12:10
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
@HelenTekie it is rounded because of your db column type, change it to decimal (18,2). See the following post stackoverflow.com/questions/25190976/…
– Access Denied
Nov 20 '18 at 12:46
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
, Nice. Now everythink is working .. Thank you
– Helen Tekie
Nov 20 '18 at 13:18
add a comment |
Try using
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text, CultureInfo.InvariantCulture);
This is nice until,
is a decimal separator in your culture.
– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
add a comment |
Try using
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text, CultureInfo.InvariantCulture);
This is nice until,
is a decimal separator in your culture.
– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
add a comment |
Try using
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text, CultureInfo.InvariantCulture);
Try using
decimal amountToWithdraw = Convert.ToDecimal(txtAmountToTransfer.Text, CultureInfo.InvariantCulture);
answered Nov 20 '18 at 8:19
Ramesh VermaRamesh Verma
5518
5518
This is nice until,
is a decimal separator in your culture.
– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
add a comment |
This is nice until,
is a decimal separator in your culture.
– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
This is nice until
,
is a decimal separator in your culture.– Access Denied
Nov 20 '18 at 8:24
This is nice until
,
is a decimal separator in your culture.– Access Denied
Nov 20 '18 at 8:24
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
As mentioned in the question, he is trying to parse values like 25.89, so a comma is not the separator in this case.
– Ramesh Verma
Nov 20 '18 at 8:27
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma In OP's question you can't see his current culture settings and he's getting error while converting. So, probably comma is separator in this case.
– SeM
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
@RameshVerma it just means that he is using incorrect separator. UI should work with UI culture and parse will work in that case.
– Access Denied
Nov 20 '18 at 8:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388749%2fhow-to-convert-textbox-string-with-decimal-to-decimal-in-c-sharp-windows-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
decimal.Parse or TryParse
– Access Denied
Nov 20 '18 at 8:15
1
duplicate: stackoverflow.com/questions/33134614/…
– JohnB
Nov 20 '18 at 8:17
1
Well, if it is a user input, then
decimal.TryParse
will be a good idea (if you do not have masked textboxes or something). And it is not converting because of your current Culture settings, I believe comma,
instead of dot.
will work.– SeM
Nov 20 '18 at 8:18
How to detect current culture separator:
char a = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
– Access Denied
Nov 20 '18 at 8:27