추가적으로 string -> int / object -> string 등이 있다.
이거 땜에 한참 찾아다녔는데 결국은 간단하게 해결
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
float numFloat;
string strText;
{
public partial class Form1 : Form
{
float numFloat;
string strText;
public Form1()
{
InitializeComponent();
}
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
strText = "100.445";
numFloat = System.Convert.ToSingle(strText);
}
}
}
{
strText = "100.445";
numFloat = System.Convert.ToSingle(strText);
}
}
}
이 외에도 오브젝트를 스트링으로 바꿔주는데는
오브젝트.ToString();
DB에서 읽어온 데이터 변환하는데도 아래와 같이 많이 쓰인다.
리더이름["컬럼명"].ToString();
(string)리더이름["컬럼명"];
오브젝트.ToString();
DB에서 읽어온 데이터 변환하는데도 아래와 같이 많이 쓰인다.
리더이름["컬럼명"].ToString();
(string)리더이름["컬럼명"];
string을 int로 변환할때는32bit(4byte)인지, 64bit인지에 따라 다른데
Int32.Parse(스트링변수등의이름);
Int64.Parse(스트링변수등의이름);
이와같이 변환 가능하다.
'General > C, C++, C#' 카테고리의 다른 글
[MFC] 윈도우 생성, 창크기 변화 후 크기 출력, 종료, 메시지출력. (0) | 2010.10.12 |
---|---|
[C언어] 방향키 입력받기 (5) | 2010.09.22 |
[C#] String -> float 캐스팅 (0) | 2009.12.23 |
[C#] MessageBox.Show() 메서드 (0) | 2009.12.18 |
[C#] 텍스트박스로 숫자 또는 일부의 문자만 입력받기 (0) | 2009.12.17 |
[C#] 로그인 기능 (일반) / 로그인 기능 (sql) (0) | 2009.11.30 |