
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Int to String in Swift
This tutorial will discuss how to write swift program to convert int type variable to string.
Swift support various datatypes and string and integers are one of them. String is an ordered collection of characters. For example: "TutorialsPoint", "Pinky", etc. To create a string-type variable we use String keyword. Whereas Integers represent numeric values like 2, 3, 45, 6, etc. And to create integer-type variables we use the Int keyword.
To convert int type variable into string we uses String() function. This function convert any data type into string.
Syntax
Following is the syntax ?
String(variableName)
Below is a demonstration of the same ?
Input
Suppose our given input is ?
Num = 52324
Output
The desired output would be ?
String = "52324"
Example
The following program shows how to convert int type variable to string.
import Foundation import Glibc // Integer type variable var mynum : Int = 23243 // Convert integer into string // Using String() function var myVar = String(mynum) print("String:", myVar) print("Type of myVar variable:", type(of: myVar))
Output
String: 23243 Type of myVar variable: String