■ CultureInfo 클래스 : GetCultures 정적 메소드를 사용해 지역별 형식 구하기
------------------------------------------------------------------------------------------------------------------------
▶ MainForm.cs
using System; using System.Globalization; using System.Windows.Forms;
namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent();
#region 이벤트를 설정한다.
Load += Form_Load;
#endregion }
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary> /// 폼 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Form_Load(object sender, EventArgs e) { float floatValue = 1234.56f; decimal decimalvalue = 1234.56m; DateTime dateTime = DateTime.Now;
foreach(CultureInfo info in CultureInfo.GetCultures(CultureTypes.AllCultures)) { ListViewItem item = this.listView.Items.Add(info.EnglishName);
item.SubItems.Add(info.NativeName); item.SubItems.Add(info.Name);
CultureInfo currentInfo = info;
while((currentInfo != null) && (currentInfo.IsNeutralCulture)) { currentInfo = currentInfo.Parent; }
if(currentInfo != null) { item.SubItems.Add(floatValue.ToString("N", currentInfo)); item.SubItems.Add(decimalvalue.ToString("C", currentInfo)); item.SubItems.Add(dateTime.ToString("d", currentInfo)); item.SubItems.Add(dateTime.ToString("t", currentInfo)); } } }
#endregion } }
|
------------------------------------------------------------------------------------------------------------------------
'C# > Common' 카테고리의 다른 글
[C#/COMMON] 외적(Cross Product) 구하기 (0) | 2019.01.01 |
---|---|
[C#/COMMON] 전원 상태 구하기 (0) | 2019.01.01 |
[C#/COMMON] Print Spooler 서비스 다시 시작하기 (0) | 2018.12.31 |
[C#/COMMON] CultureInfo 클래스 : 지역 정보 사용하기 (0) | 2018.12.31 |
[C#/COMMON] 메모리 사용률 구하기 (0) | 2018.12.31 |
[C#/COMMON] CultureInfo 클래스 : GetCultures 정적 메소드를 사용해 지역별 형식 구하기 (0) | 2018.12.30 |
[C#/COMMON] WMI를 사용해 운영 체제 정보 구하기 (0) | 2018.12.29 |
[C#/COMMON] 이집트 분수 사용하기 (0) | 2018.12.28 |
[C#/COMMON] 분수 사용하기 (0) | 2018.12.28 |
[C#/COMMON] 윈도우 종료하기 (0) | 2018.12.27 |
[C#/COMMON] 프로세서 수 구하기 (0) | 2018.12.24 |
댓글을 달아 주세요