Linked Questions

-4 votes
2 answers
961 views

People have been suggesting to use Int32.TryParse but I found out that in case of any string such as "4e",it would give me output 0(i would directly print my input),whereas Int32.Parse would give an ...
Nuruddin's user avatar
0 votes
3 answers
143 views

I have this code: public int GetIntSetting(Settings setting, int nullState) { var s = GetStringSetting(setting); if (string.IsNullOrEmpty(s)) return nullState; return int.Parse(s);...
Alan2's user avatar
  • 24.8k
0 votes
3 answers
158 views

I am doing something where I want a user to be able to enter a number between 0-9 and it spits out the word for it, eg. 1 into one. I am fine with the first part, however, I don't know how to get it ...
J. Doc's user avatar
  • 3
2 votes
3 answers
106 views

I'm trying to handle an exception to avoid my program crash if double.Parse(string) tries parsing invalid values (such as strings instead of numbers). Here's what I've got: do { //asking customer ...
Angie Castro's user avatar
0 votes
0 answers
47 views

What I am trying to achieve is write a very simple console program that continuously asks the user to enter a number or "ok" if he wants to exit. When he enters ok, the sum of all the ...
vinn23's user avatar
  • 49
49 votes
15 answers
38k views

Which of the following code is fastest/best practice for converting some object x? int myInt = (int)x; or int myInt = Convert.ToInt32(x); or int myInt = Int32.Parse(x); or in the case of a string '...
Dan McClain's user avatar
53 votes
9 answers
382k views

I want to get a number from the user, and then multiply that number with Pi. my attempt at this is below. But a contains gibberish. For example, if I insert 22, then a contains 50. What am I doing ...
MaxCoder88's user avatar
  • 2,458
25 votes
5 answers
17k views

My problem is in the context of processing data from large CSV files. I'm looking for the most efficient way to determine (that is, guess) the data type of a column based on the values found in that ...
poezn's user avatar
  • 4,169
6 votes
3 answers
17k views

private void button18_Click(object sender, EventArgs e) { Form1 stForm = new Form1(); DialogResult result = stForm.ShowDialog(this); if (result == DialogResult.Cancel) ...
Cristina 's user avatar
1 vote
5 answers
2k views

How do I add a regular expression which will accept decimal places (5.23) but nothing else in a break like so? i.e handle only numbers and decimal places which will throw an error if anything other ...
G Gr's user avatar
  • 6,070
3 votes
4 answers
8k views

Sometimes i wonder, when converting strings to other types, for example int32, is one way better than the other, or is it just a matter of taste? Convert.ToInt32("123") or Int32.Parse("123") or ...
kaze's user avatar
  • 4,379
0 votes
4 answers
4k views

I want to limit my varchar columns to have only ascii characters within a specified range, say 0-9 or A-F (for hex characters) What would my constraint look like?
Haoest's user avatar
  • 14k
2 votes
4 answers
660 views

I can't figure out how to get the try catch to work. Need to have an error message box pop up when a non number is entered in the text boxes. private void btnAdd_Click(object sender, EventArgs e) ...
sugarxfrost's user avatar
0 votes
3 answers
5k views

I'll keep this one short. I'm writing a module which will be required to compare two large integers which are input as strings (note: they are large, but not large enough to exceed Int64 bounds). ...
Michael Di Felice's user avatar
1 vote
2 answers
3k views

I am reading Data from an internal Database. The code assigns value read from the database to double. if (Convert.ToDouble(PricefromString) == Price && PriceFound == false) PricefromString ...
novice's user avatar
  • 545

15 30 50 per page