< C/C++ >
function 내부에서 static variable 선언 가능
< C# >
method 내부에서 static variable 선언 불가능
static field 선언 가능
function 내부에서 static variable 선언 가능
#include <stdio.h>
void main()
{
static int i = 0; // valid
}
void main()
{
static int i = 0; // valid
}
< C# >
method 내부에서 static variable 선언 불가능
static field 선언 가능
using System;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
static int i = 0; // compile time error
}
private static int number = 0; // valid
}
}
namespace Sample
{
class Program
{
static void Main(string[] args)
{
static int i = 0; // compile time error
}
private static int number = 0; // valid
}
}
'Code > Study' 카테고리의 다른 글
| [PerlNET] Regex (Perl C# Mix) (0) | 2008.11.09 |
|---|---|
| [Perl] Cocoa (pl pm sample) (0) | 2008.11.09 |
| [PerlNET] CIty (Mix Perl & C#) (0) | 2008.11.09 |
| [Perl] BeeConverter (Convert HTML Entity to Unicode Character) (0) | 2008.11.09 |
| [C/C++ vs C#] sizeof (0) | 2008.07.16 |