User FAQs

If you have a question, please send it to us.

1) Can you convert a string data type to an integer data type ?
Yes. There are several ways this can be done.

int i; 
i = (int)myString;
i = (System.Int32)myString;
i = myString as int;
i = myString as System.Int32;
i = System.Convert.ToInt32(myString);
i = System.Int32.Parse(myString);

2) Can you convert an integer data type to a string data type ?
Yes. There are several ways this can be done.

int i = 10; 
string s;
s = i.ToString();
s = System.Convert.ToString(i);
s = System.String.Format("{0}",i);
s = $"{i}";
s = "" + i;
s = System.String.Empty + i;
s = new System.Text.StringBuilder().Append(i).ToString();

3) What is Arithmetic Overflow and Underflow ?
When you perform an integer arithmetic operation and the result goes outside the range of the data type.
To modify and control overflow/underflow there are two keywords you can use 'checked' and 'unchecked'.
In a checked context, arithmetic overflow raises an exception.
In an unchecked context, arithmetic overflow is ignored and the result is truncated or wrapped. This is the default context.
Code where unexpected wrapping arithmetic needs to be detected you should use checked context.
Code that relies on wrapping arithmetic should use unchecked context.

int myInt = 2147483647 + 10; 
// this line generates a compile-time error

int number = 10
int myInt2 = 2147483647 + number;
// this line does not generate a compile time error or a run-time exception

   int number = 10;
   int myInt2 = 2147483647 + number;
    // this line generates an overflow run-time exception

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext