C# 電卓処理分析中
文字 char = ''
正直 普段あんま使わないけど、判定には便利。
Example
char = 'a'
char = 'あ'
char = '+'
文字列 string =" "
IsDigit = 文字(char )の判定。
今回の電卓だと
文字列を一文字ずつ判別
左から一文字ずつ読み取る
数字
↓
boolは一回だけ処理したい場合とかに使う。
理解の為にやってること。
・大まかな処理をつかむ
・可能な限り細かく分析。
・自分の知っている機能か確認しつつ、分割して記述
・理解した処理を参考に書いてみる
・1から作るのでも繰り返す
展望
→別処理の配列型も理解したい
<<解体・分析中>>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
double stack = 0.0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
public void Cal()
{
if (textBox1.Text == "+")
{
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
private void button4_Click(object sender, EventArgs e)
{
double left = 0.0;
double right = 0.0;
string copy = string.Empty;
for (int i = 0; i < textBox1.Text.Length; ++i )
{
char Char_Temp = textBox1.Text[i];
if (Char.IsDigit(Char_Temp) == true)
{
copy += Char_Temp;
}
if (Char_Temp == '+')
{
textBox2.Text = "+";
left = double.Parse(copy);
textBox2.Text += left;
}
}
}
}
}