
- Swift Tutorial
- Swift - Home
- Swift - Overview
- Swift - Environment
- Swift - Basic Syntax
- Swift - Data Types
- Swift - Variables
- Swift - Optionals
- Swift - Tuples
- Swift - Constants
- Swift - Literals
- Swift - Operators
- Swift - Decision Making
- Swift - Loops
- Swift - Strings
- Swift - Characters
- Swift - Arrays
- Swift - Sets
- Swift - Dictionaries
- Swift - Functions
- Swift - Closures
- Swift - Enumerations
- Swift - Structures
- Swift - Classes
- Swift - Properties
- Swift - Methods
- Swift - Subscripts
- Swift - Inheritance
- Swift - Initialization
- Swift - Deinitialization
- Swift - ARC Overview
- Swift - Optional Chaining
- Swift - Type Casting
- Swift - Extensions
- Swift - Protocols
- Swift - Generics
- Swift - Access Control
- Swift Useful Resources
- Swift - Compile Online
- Swift - Quick Guide
- Swift - Useful Resources
- Swift - Discussion
Swift Program to convert int type variable to string
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
- Related Articles
- Swift Program to convert int type variable to double
- Swift program to convert double type variable to string
- Swift program to convert string type variable into boolean
- Swift Program to Convert Char type variables to Int
- Swift program to convert double type variables to int
- Golang Program to convert int type variables to String
- Haskell Program to convert int type variables to String
- Swift program to convert boolean variable into string
- C++ Program to Convert int Type Variables into String
- Golang Program to convert string type variables into int
- Haskell Program to convert string type variables into int
- Haskell Program to convert int type variables to char
- Haskell Program to convert int type variables to long
- Golang Program to convert long type variables to int
- Golang Program to convert int type variables to long
