C# 초보 질문입니다.

pavil의 이미지

HeadFirst C#책에 나오는 연습문제입니다.
생성된 윈도우 창에 있는 버튼을 눌러서 색깔이 계속 변하게 만드는 예제인데요, 질문 내용은 아래와 같습니다.

private void button1_Click(object sender, EventArgs e)
        {
            while(Visible)
            {
                for (int i = 254; i >= 0 && Visible; i--)
                {
                    this.BackColor = Color.FromArgb(i, 255 - i, i);
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(3);
                }
 
                for (int i = 0; i <= 253 && Visible; i++)
                {
                    this.BackColor = Color.FromArgb(i, 255 - i, i);
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(3);
                }
            }
        }

여기서 for문 조건에 && Visible 이 들어가야 창이 닫히자 마자 프로그램이 종료되더라구요.
&& Visible이 없으면 창이 닫힌뒤 1초정도 더 있어야 프로그램이 완전히 종료됩니다.
while문이 닫히면 for문은 자동적으로 닫히는게 아닌가요? 이해가 잘 되지 않습니다.

shint의 이미지

http://codepad.org/

#include <stdio.h>
 
int main(int argc, char** argv)
{
    int i;
 
    i=0;
    printf("%d >= 0 && 0    [ %d]\n", i, i >= 0 && 0);
    printf("%d >= 0 && 1    [ %d]\n", i, i >= 0 && 1);
    printf("\n");
 
    i=1;
    printf("%d >= 0 && 0    [ %d]\n", i, i >= 0 && 0);
    printf("%d >= 0 && 1    [ %d]\n", i, i >= 0 && 1);
    printf("\n");
 
    i=2;
    printf("%d >= 0 && 0    [ %d]\n", i, i >= 0 && 0);
    printf("%d >= 0 && 1    [ %d]\n", i, i >= 0 && 1);
    printf("\n");
 
    i=0;
    printf("%d >= 0 & 0    [ %d]\n", i, i >= 0 & 0);
    printf("%d >= 0 & 1    [ %d]\n", i, i >= 0 & 1);
    printf("\n");
 
    i=1;
    printf("%d >= 0 & 0    [ %d]\n", i, i >= 0 & 0);
    printf("%d >= 0 & 1    [ %d]\n", i, i >= 0 & 1);
    printf("\n");
 
    i=2;
    printf("%d >= 0 & 0    [ %d]\n", i, i >= 0 & 0);
    printf("%d >= 0 & 1    [ %d]\n", i, i >= 0 & 1);    
    printf("\n");
 
	return 0;
}
 
#if 0
0 >= 0 && 0    [0]
0 >= 0 && 1    [1]
 
1 >= 0 && 0    [0]
1 >= 0 && 1    [1]
 
2 >= 0 && 0    [0]
2 >= 0 && 1    [1]
 
0 >= 0 & 0    [0]
0 >= 0 & 1    [1]
 
1 >= 0 & 0    [0]
1 >= 0 & 1    [1]
 
2 >= 0 & 0    [0]
2 >= 0 & 1    [1]
#endif

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

shint의 이미지


UNICODE NORMALIZATION FORMS
http://unicode.org/reports/tr15/tr15-33.html

public int quickCheck(String source) {
short lastCanonicalClass = 0;
int result = YES;
for (int i = 0; i < source.length(); ++i) {
char ch = source.charAt(i);
short canonicalClass = getCanonicalClass(ch);
if (lastCanonicalClass > canonicalClass && canonicalClass != 0) {
return NO; }
int check = isAllowed(ch);
if (check == NO) return NO;
if (check == MAYBE) result = MAYBE;
lastCanonicalClass = canonicalClass;
}
return result;
}

public static final int NO = 0, YES = 1, MAYBE = -1;

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.