Tuesday, September 15, 2015

int to string, string to int conversion c# unity

iklan
Code :-
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ConversionScript : MonoBehaviour {

    int inumber = 12;
    float fnumber = 24.5f;
    string sname = "Satya";

    int TestNumber;
    float TestFnumber;
    string TestName;


    public InputField ScoreField;
    int score;
    public Text scoreText;
    void Start () {

        TestName = inumber.ToString(); // int to string conversion
        TestNumber = int.Parse(sname); // string to int conversion

        TestNumber =  (int)fnumber// float to int conversion
        TestFnumber = inumber// int to float conversion

        TestName = fnumber.ToString(); // float to string conversion

    }

    void Update()
    {
        score = int.Parse(ScoreField.text);
        Debug.Log ("Input field Score :"+score);

        scoreText.text = score.ToString();
    }

}






int to string, string to int conversion c# unity
4/ 5
Oleh