본문 바로가기
코스웨어/16년 스마트컨트롤러

2016-05-18_조재찬_스터디일지_ C#-설문조사 APP, 기초복습

by 알 수 없는 사용자 2016. 5. 19.
728x90
반응형

설문조사 APP 구현


Form 디자인




제출버튼(btnPoll)을 클릭했을때의 코드 추가

/*

foreach (컬렉션의 요소를 반복하는데 사용되는 변수 in Object 변수)

{

// 실행문;

}

*/


 private void btnPoll_Click(object sender, EventArgs e)
        {
            if(this.CB1.Checked!=false||this.CB2.Checked!=false)
            {
                foreach(RadioButton c in this.GB_Hobby.Controls)
                {
                    if (c.Checked == true)
                        this.Label_Hobby.Text = c.Text;
                }
                this.Label_Singer.Text = "";
                foreach (CheckBox c in this.GB_Singer.Controls)
                {
                    if(c.Checked==true)
                    {
                        this.Label_Singer.Text += c.Text +"  ";
                    }
                }
            }
        }


Output : 


라디오 버튼과 체크박스(중복선택 가능)를 통해 설문에 응답하고 결과 제출



제출결과는 아래 (Panel_Result)에 표시된다.


프로젝트 파일

poll.7z






C# 기초 복습



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bool
{
    class MainApp
    {
        static void Main(string[] args)
        {
        bool a = true;
        bool b = false;

        Console.WriteLine(a);
        Console.WriteLine(b);
        }
    }    
}

Output:

True

False  


bool은 true, false 데이터를 다루며 1바이트 크기의 type이다. (1비트만으로 표현가능하지만 컴퓨터가 기본적으로 바이트 단위를 사용하므로)



Object 형식 : 어떤 형식의 데이터라도 object 담아 처리할 수 있다. (int, long, char, bool, string...)

ex) object a=123;    object b=3.14f;    object c = true;    object d = "hello";


12345

3.14


False
True
True
True
3


True
False
10
11
12
50
51


728x90