C# int data type

int is a 32 bit signed integer type, ranges from -2,147,483,648 to 2,147,483,647, -216 to 216.

int i=3;

int and string conversion.
using System.Windows.Forms;
int i=3;
string str = i.ToString();
MessageBox.Show(str); //3
string str = "4";
int j = Int16.Parse(str);
MessageBox.Show(j.ToString()); //4

int array.
int[] arr = {2,4,6,8};
int sum=0;
foreach (int i in arr) sum += i;

int to float.
int i=3;
float j=(float)i;



endmemo.com © 2024  | Terms of Use | Privacy | Home