using System;
class Program
{
static void Main()
{
string s1, s2, s3;
int i1, i2, i3, i4;
// convert String to Int
s1 = "23";
i1 = Int32.Parse(s1);
i2 = Convert.ToInt32(s1);
i3 = int.Parse(s1);
Console.WriteLine(i1 + ", " + i2 + ", " + i3);
// convert Int to String
i4 = 79;
s2 = Convert.ToString(i4);
s3 = i4.ToString();
Console.WriteLine(s2 + ", " + s3);
Console.ReadKey();
}
}
|
Class Program
Private Shared Sub Main()
Dim s1 As String, s2 As String, s3 As String
Dim i1 As Integer, i2 As Integer, i3 As Integer, i4 As Integer
' convert String to Int
s1 = "23"
i1 = Int32.Parse(s1)
i2 = Convert.ToInt32(s1)
i3 = Integer.Parse(s1)
Console.WriteLine(i1 + ", " + i2 + ", " + i3)
' convert Int to String
i4 = 79
s2 = Convert.ToString(i4)
s3 = i4.ToString()
Console.WriteLine(Convert.ToString(s2 & Convert.ToString(", ")) & s3)
Console.ReadKey()
End Sub
End Class
|