BASIC4MCU | 질문게시판 | c#에서는 var 변수를 못쓰는건가요?
페이지 정보
작성자 master 작성일2018-09-16 09:27 조회39,687회 댓글0건본문
원래 var가 자바에서 쓰이는 변수인지는 알지만, 막상 구글에 c#에서 var변수형을 쓸수 없나 검색해보면 쓸 수 있다고 나오더라고요? 심지어 마이크로소프트 공식 홈페이지 c# 영역에서도 var변수형을 쓰고 있길래 질문드립니다.
//
var가 원래 자바에서 사용하던 선언은 아닌 것 같고요
자바와 C#을 거꾸로 조사해보죠
2000 | C# | Anders Hejlsberg, Microsoft (ECMA) | C, C++, Java, Delphi, Modula-2 |
우측에 보면 C#은 자바도 참고 했다고 적혀있습니다.
1989 | Turbo Pascal OOP | Anders Hejlsberg at Borland | Turbo Pascal, Object Pascal |
1995 | Borland Delphi | Anders Hejlsberg at Borland | Borland Pascal |
2000 | C# | Anders Hejlsberg, Microsoft (ECMA) | C, C++, Java, Delphi, Modula-2 |
1995 | Java | James Gosling at Sun Microsystems | C, Simula 67, C++, Smalltalk, Ada 83, Objective-C, Mesa |
Timeline of programming languages
Pre-1950
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
1804 | Jacquard Loom | Joseph Marie Jacquard | none (unique language) |
1943–45 | Plankalkül (concept) | Konrad Zuse | none (unique language) |
1943–46 | ENIAC coding system | John von Neumann, John Mauchly, J. Presper Eckert, Herman Goldstineafter Alan Turing | none (unique language) |
1946 | ENIAC Short Code | Richard Clippinger, John von Neumann after Alan Turing | ENIAC coding system |
1946 | Von Neumann and Goldstine graphing system(Notation) | John von Neumann and Herman Goldstine | ENIAC coding system |
1947 | ARC Assembly | Kathleen Booth[1][2] | ENIAC coding system |
1948 | CPC Coding scheme | Howard H. Aiken | Analytical Engine order code |
1948 | Curry notation system | Haskell Curry | ENIAC coding system |
1948 | Plankalkül (concept published) | Konrad Zuse | none (unique language) |
1949 | Short Code | John Mauchly and William F. Schmitt | ENIAC Short Code |
1950s
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
1950 | Short Code | William F Schmidt, Albert B. Tonik,[3] J.R. Logan | Brief Code |
1950 | Birkbeck Assembler | Kathleen Booth | ARC |
1951 | Superplan | Heinz Rutishauser | Plankalkül |
1951 | ALGAE | Edward A Voorhees and Karl Balke | none (unique language) |
1951 | Intermediate Programming Language | Arthur Burks | Short Code |
1951 | Regional Assembly Language | Maurice Wilkes | EDSAC |
1951 | Boehm unnamed coding system | Corrado Böhm | CPC Coding scheme |
1951 | Klammerausdrücke | Konrad Zuse | Plankalkül |
1951 | OMNIBAC Symbolic Assembler | Charles Katz | Short Code |
1951 | Stanislaus (Notation) | Fritz Bauer | none (unique language) |
1951 | Whirlwind assembler | Charles Adams and Jack Gilmore at MIT Project Whirlwind | EDSAC |
1951 | Rochester assembler | Nat Rochester | EDSAC |
1951 | Sort Merge Generator | Betty Holberton | none (unique language) |
1952 | A-0 | Grace Hopper | Short Code |
1952 | Glennie Autocode | Alick Glennie after Alan Turing | CPC Coding scheme |
1952 | Editing Generator | Milly Koss | SORT/MERGE |
1952 | COMPOOL | RAND/SDC | none (unique language) |
1953 | Speedcoding | John W. Backus | none (unique language) |
1953 | READ/PRINT | Don Harroff, James Fishman, George Ryckman | none (unique language) |
1954 | Laning and Zierler system | Laning, Zierler, Adams at MIT Project Whirlwind | none (unique language) |
1954 | Mark I Autocode | Tony Brooker | Glennie Autocode |
1954–55 | Fortran (concept) | Team led by John W. Backus at IBM | Speedcoding |
1954 | ARITH-MATIC | Team led by Grace Hopper at UNIVAC | A-0 |
1954 | MATH-MATIC | Team led by Charles Katz | A-0 |
1954 | MATRIX MATH | H G Kahrimanian | none (unique language) |
1954 | IPL I (concept) | Allen Newell, Cliff Shaw, Herbert A. Simon | none (unique language) |
1955 | FLOW-MATIC | Team led by Grace Hopper at UNIVAC | A-0 |
1955 | BACAIC | M. Grems and R. Porter | |
1955 | PACT I | SHARE | FORTRAN, A-2 |
1955 | Freiburger Code[4][5] | University of Freiburg | N/A |
1955–56 | Sequentielle Formelübersetzung | Fritz Bauer and Karl Samelson | Boehm |
1955–56 | IT | Team led by Alan Perlis | Laning and Zierler |
1955 | IBM | ||
1956–58 | LISP (concept) | John McCarthy | IPL |
1957 | COMTRAN | Bob Bemer | FLOW-MATIC |
1957 | GEORGE | Charles Leonard Hamblin | none (unique language) |
1957 | Fortran I (implementation) | John W. Backus at IBM | FORTRAN |
1957–58 | UNICODE | Remington Rand UNIVAC | MATH-MATIC |
1957 | COMIT (concept) | none (unique language) | |
1958 | IPL II (implementation) | Allen Newell, Cliff Shaw, Herbert A. Simon | IPL I |
1958 | Fortran II | Team led by John W. Backus at IBM | FORTRAN I |
1958 | ALGOL 58 (IAL) | ACM/GAMM | FORTRAN, IT, Sequentielle Formelübersetzung |
1958 | IPL V | Allen Newell, Cliff Shaw, Herbert A. Simon | IPL II |
1959 | APT | Douglas T. Ross | |
1959 | FACT | Fletcher R. Jones, Roy Nutt, Robert L. Patrick | none (unique language) |
1959 | COBOL (concept) | The CODASYL Committee | FLOW-MATIC, COMTRAN, FACT |
1959 | JOVIAL | Jules Schwartz at SDC | ALGOL 58 |
1959 | LISP (implementation) | John McCarthy | IPL |
1959 | MAD – Michigan Algorithm Decoder | Bruce Arden, Bernard Galler, and Robert M. Graham | ALGOL 58 |
1959 | TRAC (concept) | Calvin Mooers |
1960s
1970s
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
1970? | Forth (implementation) | Charles H. Moore | |
1970 | POP-2 | Robin Popplestone | POP-1 |
1970 | Pascal | Niklaus Wirth, Kathleen Jensen | ALGOL 60, ALGOL W |
1970 | BLISS | Wulf, Russell, Habermann at Carnegie Mellon University | ALGOL |
1971 | KRL | Daniel G. Bobrow at Xerox PARC, Terry Winograd at Stanford University | KM, FRL (MIT) |
1971 | Sue | Ric Holt et al. at University of Toronto | Pascal, XPL |
1971 | Compiler Description Language (CDL) | Cornelis H.A. Koster at University of Nijmegen | |
1972 | Smalltalk | Alan Kay, Adele Goldberg, Dan Ingalls, Xerox PARC | Simula 67 |
1972 | PL/M | Gary Kildall at Digital Research | PL/I, ALGOL, XPL |
1972 | C | Dennis Ritchie | B, BCPL, ALGOL 68 |
1972 | INTERCAL | Don Woods and James M. Lyon | none (unique language) |
1972 | Prolog | Alain Colmerauer | 2-level W-Grammar |
1972 | Structured Query language (SQL) | IBM | ALPHA, Quel (Ingres) |
1973 | COMAL | Børge Christensen, Benedict Løfstedt | Pascal, BASIC |
1973 | ML | Robin Milner | |
1973 | LIS | Jean Ichbiah et al. at CII Honeywell Bull | Pascal, Sue |
1973 | Speakeasy-3 | Stanley Cohen, Steven Pieper at Argonne National Laboratory | Speakeasy-2 |
1974 | CLU | Barbara Liskov | ALGOL 60, Lisp, Simula |
1974 | GRASS | Thomas A. DeFanti | BASIC |
1974 | BASIC FOUR | MAI BASIC Four Inc. | Business BASIC |
1974 | PROSE modeling language | CDC 6600 Cybernet Services | SLANG, FORTRAN |
1975 | ABC | Leo Geurts and Lambert Meertens | SETL |
1975 | Irvine Dataflow (concept) | Arvind?, University of California, Irvine | |
1975 | PROSE modeling language Time-Sharing Version | CDC 6400 Cybernet KRONOS Services | SLANG, FORTRAN |
1975 | Scheme | Gerald Jay Sussman, Guy L. Steele, Jr. | LISP |
1975 | Altair BASIC | Bill Gates, Paul Allen | BASIC |
1975 | CS-4 | James S. Miller, Benjamin M. Brosgol et al. at Intermetrics | ALGOL 68, BLISS, ECL, HAL |
1975 | Modula | Niklaus Wirth | Pascal |
1976 | Plus | Allan Ballard, Paul Whaley at the University of British Columbia | Pascal, Sue |
1976 | Smalltalk-76 | Xerox PARC | Smalltalk-72 |
1976 | Mesa | Xerox PARC | ALGOL |
1976 | SAM76 | Claude A.R. Kagan | LISP, TRAC |
1976 | Ratfor | Brian Kernighan | C, FORTRAN |
1976 | S | John Chambers at Bell Labs | APL, PPL, Scheme |
1976 | SAS | SAS Institute | |
1976 | Integer BASIC | Steve Wozniak | BASIC |
1977 | FP | John Backus | none (unique language) |
1977 | Bourne Shell (sh) | Stephen R. Bourne | none (unique language) |
1977 | Commodore BASIC | Jack Tramiel | BASIC |
1977 | IDL | David Stern of Research Systems Inc | Fortran |
1977 | Standard MUMPS | MUMPS | |
1977 | Icon (concept) | Ralph Griswold | SNOBOL |
1977 | Red | Benjamin M. Brosgol et al. at Intermetrics for US Dept of Defense | ALGOL 68, CS-4 |
1977 | Blue | John B. Goodenough et al. at SofTech for US Dept of Defense | ALGOL 68 |
1977 | Yellow | Jay Spitzen et al. at SRI International for US Dept of Defense | ALGOL 68 |
1977 | Euclid | Butler Lampson at Xerox Parc, Ric Holt and James Cordy at University of Toronto | |
1977 | Applesoft BASIC | Marc McDonald and Ric Weiland | BASIC |
1978 | RAPT | Pat Ambler and Robin Popplestone | APT |
1978 | C shell | Bill Joy | C |
1978 | RPG III | IBM | FARGO, RPG, RPG II |
1978 | HAL/S | designed by Intermetrics for NASA | XPL |
1978 | Applesoft II BASIC | Marc McDonald and Ric Weiland | Applesoft BASIC |
1975 | Irvine Dataflow (implementation) | Arvind and Gostelow, University of California, Irvine | |
1978? | MATLAB | Cleve Moler at the University of New Mexico | Fortran |
1978? | SMALL | Nevil Brownlee at the University of Auckland | Algol60 |
1978 | VisiCalc | Dan Bricklin, Bob Frankston marketed by VisiCorp | none (unique language) |
1979 | Modula-2 | Niklaus Wirth | Modula, Mesa |
1979 | REXX | Mike Cowlishaw at IBM | PL/I, BASIC, EXEC 2 |
1979 | AWK | Alfred Aho, Peter J. Weinberger, Brian Kernighan | C, SNOBOL |
1979 | Icon (implementation) | Ralph Griswold | SNOBOL |
1979 | Vulcan dBase-II | Wayne Ratliff | none (unique language) |
1980s
1990s
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
1990 | AMOS BASIC | François Lionet and Constantin Sotiropoulos | STOS BASIC |
1990 | AMPL | Robert Fourer, David Gay and Brian Kernighan at Bell Laboratories | |
1990 | Object Oberon | H Mössenböck, J Templ, R Griesemer | Oberon |
1990 | J | Kenneth E. Iverson, Roger Hui at Iverson Software | APL, FP |
1990 | Haskell | Miranda | |
1990 | EuLisp | Common Lisp, Scheme | |
1990 | Z Shell (zsh) | Paul Falstad at Princeton University | ksh |
1991 | GNU E | David J. DeWitt, Michael J. Carey | C++ |
1991 | Oberon-2 | Hanspeter Mössenböck, Wirth | Object Oberon |
1991 | Python | Guido van Rossum | ABC, ALGOL 68, Icon, Modula-3 |
1991 | Oz | Gert Smolka and his students | Prolog |
1991 | Q | Albert Gräf | |
1991 | Visual Basic | Alan Cooper, sold to Microsoft | QuickBASIC |
1992 | Borland Pascal | Turbo Pascal OOP | |
1992 | Dylan | many people at Apple Computer Inc. | Common Lisp, Scheme |
1992 | S-Lang | John E. Davis | PostScript |
1993? | Self (implementation) | Sun Microsystems Inc. | Smalltalk |
1993 | Amiga E | Wouter van Oortmerssen | DEX, C, Modula-2 |
1993 | Brainfuck | Urban Müller | P′′ |
1993 | LiveCode Transcript | HyperTalk | |
1993 | AppleScript | Apple Computer Inc. | HyperTalk |
1993 | K | Arthur Whitney | APL, Lisp |
1993 | Lua | Roberto Ierusalimschy et al. at Tecgraf, PUC-Rio | Scheme, SNOBOL, Modula, CLU, C++ |
1993 | R | Robert Gentleman and Ross Ihaka | S |
1993 | ZPL | Chamberlain et al. at University of Washington | C |
1993 | NewtonScript | Walter Smith | Self, Dylan |
1993 | Euphoria | Robert Craig | SNOBOL, AWK, ABC, Icon, Python |
1994 | Claire | Yves Caseau | Smalltalk, SETL, OPS5, Lisp, ML, C, LORE, LAURE |
1994 | ANSI Common Lisp | Common Lisp | |
1994 | RAPID | ABB Group | ARLA |
1994 | Pike | Fredrik Hübinette et al. at Linköping University | LPC, C, µLPC |
1994 | ANS Forth | Elizabeth Rather, et al. | Forth |
1995 | Ada 95 | S. Tucker Taft, et al. at Intermetrics, Inc. | Ada 83 |
1995 | Borland Delphi | Anders Hejlsberg at Borland | Borland Pascal |
1995 | ColdFusion (CFML) | Allaire | |
1995 | Java | James Gosling at Sun Microsystems | C, Simula 67, C++, Smalltalk, Ada 83, Objective-C, Mesa |
1995 | LiveScript | Brendan Eich at Netscape | Self, C, Scheme |
1995 | Mercury | Zoltan Somogyi at University of Melbourne | Prolog, Hope, Haskell |
1995 | PHP | Rasmus Lerdorf | Perl |
1995 | Ruby | Yukihiro Matsumoto | Smalltalk, Perl |
1995 | JavaScript | Brendan Eich at Netscape | LiveScript |
1995 | Racket | Matthew Flatt at Rice University | Scheme, Lisp |
1996 | Curl | David Kranz, Steve Ward, Chris Terman at MIT | Lisp, C++, Tcl/Tk, TeX, HTML |
1996 | Lasso | Blue World Communications Inc. | |
1996 | Perl Data Language (PDL) | Karl Glazebrook, Jarle Brinchmann, Tuomas Lukka, and Christian Soeller | APL, Perl |
1996 | VBScript | Microsoft | Visual Basic |
1996 | OCaml | INRIA | Caml Light, Standard ML |
1996 | NetRexx | Mike Cowlishaw | REXX |
1997 | Component Pascal | Oberon microsystems, Inc | Oberon-2 |
1997 | E | Mark S. Miller | Joule, Original-E |
1997 | Pico | Free University of Brussels | Scheme |
1997 | Squeak Smalltalk | Alan Kay, et al. at Apple Computer Inc. | Smalltalk-80, Self |
1997 | ECMAScript | ECMA TC39-TG1 | JavaScript |
1997 | F-Script | Philippe Mougin | Smalltalk, APL, Objective-C |
1997 | ISLISP | ISO Standard ISLISP | Common Lisp |
1997 | Tea | Jorge Nunes | Java, Scheme, Tcl |
1997 | REBOL | Carl Sassenrath, Rebol Technologies | Self, Forth, Lisp, Logo |
1998 | Logtalk | Paulo Moura (then at University of Coimbra) | Prolog |
1998 | ActionScript | Gary Grossman | ECMAScript |
1998 | Standard C++ | ANSI/ISO Standard C++ | C++, Standard C, C |
1998 | M2001 | Ronald E. Prather, Trinity University (Texas) | none (unique language) |
1998 | Pikt | Robert Osterlund (then at University of Chicago) | AWK, Perl, Unix shell |
1998 | PureBasic | Frederic Laboureur, Fantaisie Software | |
1998 | UnrealScript | Tim Sweeney at Epic Games | C++, Java |
1998 | XSLT (+ XPath) | W3C, James Clark | DSSSL |
1999 | Game Maker Language(GML) | Mark Overmars | Game Maker |
1999 | Harbour | Antonio Linares | dBase |
2000s
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
2000 | Join Java | G Stewart von Itzstein | Java |
2000 | DarkBasic | The Game Creators Ltd. | |
2000 | C# | Anders Hejlsberg, Microsoft (ECMA) | C, C++, Java, Delphi, Modula-2 |
2001 | Joy | Manfred von Thun | FP, Forth |
2001 | AspectJ | Gregor Kiczales, Xerox PARC | Java, Common Lisp |
2001 | D | Walter Bright, Digital Mars | C, C++, C#, Java |
2001 | Processing | Casey Reas and Benjamin Fry | Java, C, C++[8] |
2001 | Visual Basic .NET | Microsoft | Visual Basic |
2001 | RPG IV (RPGLE, ILE RPG, RPG Free) | IBM | FARGO, RPG, RPG II, RPG III, RPG/400 |
2001 | GDScript (GDS) | OKAM Studio | Godot |
2002 | Io | Steve Dekorte | Self, NewtonScript, Lua |
2002 | Gosu | Guidewire Software | GScript |
2002 | PlayBasic | Kevin Picone | |
2002 | Scratch | Mitchel Resnick, John Maloney, Natalie Rusk, Evelyn Eastmond, Tammy Stern, Amon Millner, Jay Silver, and Brian Silverman | Logo, Smalltalk, Squeak, E-Toys, HyperCard, AgentSheets, StarLogo, Tweak, BYOB |
2003 | Nemerle | University of Wrocław | C#, ML, MetaHaskell |
2003 | Factor | Slava Pestov | Joy, Forth, Lisp |
2003 | Falcon | Giancarlo Niccolai | C++, Perl, Lua, Smalltalk, PHP, Lisp, Python, Ruby |
2003 | Scala | Martin Odersky | Smalltalk, Java, Haskell, Standard ML, OCaml |
2003 | C++03 | C++ ISO/IEC 14882:2003 | C++, Standard C, C |
2003 | Squirrel | Alberto Demichelis | Lua |
2003 | Boo | Rodrigo B. de Oliveira | Python, C# |
2004 | Subtext | Jonathan Edwards | none (unique language) |
2004 | Alma-0 | Krzysztof Apt, Centrum Wiskunde & Informatica | none (unique language) |
2004 | FreeBASIC | Andre Victor | QBasic |
2004 | Groovy | James Strachan | Java |
2004 | Little b | Aneil Mallavarapu, Harvard Medical School, Department of Systems Biology | Lisp |
2005 | Fantom | Brian Frank, Andy Frank | C#, Scala, Ruby, Erlang |
2005 | F# | Don Syme, Microsoft Research | OCaml, C#, Haskell |
2005 | Haxe | Nicolas Cannasse | ActionScript, OCaml, Java |
2005 | Oxygene | RemObjects Software | Object Pascal, C# |
2005 | Seed7 | Thomas Mertes | none (unique language) |
2006 | Links | Philip Wadler, University of Edinburgh | Haskell |
2006 | Cobra | ChuckEsterbrook | Python, C#, Eiffel, Objective-C |
2006 | Windows PowerShell | Microsoft | C#, ksh, Perl, CL, DCL, SQL |
2006 | OptimJ | Ateji | Java |
2006 | Fortress | Guy Steele | Scala, ML, Haskell |
2006 | Vala | GNOME | C# |
2007 | Ada 2005 | Ada Rapporteur Group | Ada 95 |
2007 | Agda | Ulf Norell | Coq, Epigram, Haskell |
2007 | QB64 | Galleon, QB64Team | QBasic |
2007 | Clojure | Rich Hickey | Lisp, ML, Haskell, Erlang |
2007 | LOLCODE | Adam Lindsay | none (unique language) |
2007 | Oberon-07 | Wirth | Oberon |
2007 | Swift (parallel scripting language) | University of Chicago, Argonne National Laboratory | |
2008 | Nim | Andreas Rumpf | Python, Lisp, Object Pascal |
2008 | Genie | Jamie McCracken | Python, Boo, D, Object Pascal |
2008 | Pure | Albert Gräf | Q |
2009 | Chapel | Brad Chamberlain, Cray Inc. | HPF, ZPL |
2009 | Go | C, Oberon, Limbo, Smalltalk | |
2009 | CoffeeScript | Jeremy Ashkenas | JavaScript, Ruby, Python, Haskell |
2009 | Idris | Edwin Brady | Haskell, Agda, Coq |
2009 | Parasail | S. Tucker Taft, AdaCore | Modula, Ada, Pascal, ML |
2009 | Whiley | David J. Pearce | Java, C, Python |
2009 | Dafny | K. Rustan M. Leino | Java, Spec# |
2010s
Year | Name | Chief developer, company | Predecessor(s) |
---|---|---|---|
Year | Name | Chief developer, company | Predecessor(s) |
2010 | Rust | Graydon Hoare, Mozilla | Alef, C++, Camlp4, Erlang, Hermes, Limbo, Napier, Napier88, Newsqueak, NIL,Sather, Standard ML |
2011 | Ceylon | Gavin King, Red Hat | Java |
2011 | Dart | Java, JavaScript, CoffeeScript, Go | |
2011 | C++11 | C++ ISO/IEC 14882:2011 | C++, Standard C, C |
2011 | Kotlin | JetBrains | Java, Scala, Groovy, C#, Gosu |
2011 | Red | Nenad Rakocevic | Rebol, Scala, Lua |
2011 | MonkeyX | Mark Sibly | |
2011 | Opa | MLstate | OCaml, Erlang, JavaScript |
2012 | Elixir | José Valim | Erlang, Ruby, Clojure |
2012 | Elm | Evan Czaplicki | Haskell, Standard ML, OCaml, F# |
2012 | TypeScript | Anders Hejlsberg, Microsoft | JavaScript, CoffeeScript |
2012 | Julia | Jeff Bezanson, Stefan Karpinski, Viral Shah, Alan Edelman, MIT | MATLAB, Lisp, C, Fortran, Mathematica[9] (strictly its Wolfram Language), Python,Perl, R, Ruby, Lua[10] |
2012 | P | Vivek Gupta, Ethan Jackson, Shaz Qadeer, Sriram Rajamani, Microsoft | |
2012 | Ada 2012 | ARA and Ada Europe (ISO/IEC 8652:2012) | Ada 2005, ISO/IEC 8652:1995/Amd 1:2007 |
2013 | P4 | P4 Language Consortium (P4.org) | |
2013 | Cuneiform | Jörgen Brandt | Swift (parallel scripting language) |
2014 | Crystal | Ary Borenszweig, Manas Technology Solutions | Ruby, C, Rust, Go, C#, Python |
2014 | Hack | PHP | |
2014 | Swift | Apple Inc. | Objective-C, Rust, Haskell, Ruby, Python, C#, CLU |
2014 | C++14 | C++ ISO/IEC 14882:2014 | C++, Standard C, C |
2015 | Perl 6 | The Rakudo Team | Perl, Haskell, Python, Ruby |
2015 | SpiderBasic | Frederic Laboureur, Fantaisie Software | |
2016 | Ring | Mahmoud Fayed | Lua, Python, Ruby, C, C#, BASIC, QML, xBase, Supernova |
2017 | C++17 | C++ ISO/IEC 14882:2017 | C++, Standard C, C |
2017 | CerberusX | Michael Hartlef, Martin Leidel | MonkeyX |
2017 | Ballerina | WSO2, Open Source[11] | |
2018 | Fortran 2018 | ISO/IEC JTC1/SC22/WG5 N2150:2018 | Fortran 2008 |
See also
1970 | Pascal | Niklaus Wirth, Kathleen Jensen | ALGOL 60, ALGOL W |
1972 | C | Dennis Ritchie | B, BCPL, ALGOL 68 |
C#이라는 언어가 처음 세상에 나왔을 때는 기존의 다른 컴파일 언어들과 비슷하게 명시적 타입 선언만을 제공하였다.
예를 들어
- 문자열을 선언할 경우 : string name;
- 정수형을 선언할 경우 : int number;
와 같이 선언을 하였다. 하지만 Functional Programming, LINQ 와 같은 개념 혹은 스펙이 추가 되면서 다양한 타입 선언 방식을 제공하고 있다. 여기서는 기존 명시적 타입 선언 이외에 var, dynamic, object 의 공통점 및 차이점에 대해 알아 보도록 하겠다.
object
어떠한 타입이라도 변수로 선언하여 사용할 수 있다. 단 값 형식(value type)을 참조형식(reference type)으로 다시 참조형식을 값 형식으로 형 변환을 할 경우 박싱(boxing : 값형식 -> 참조형식), 언박싱(unboxing : 참조형식 -> 값형식) 과정이 일어나며, 성능상 영향을 미칠 수 있다.
var
var(Local Variable Type)은 C# 3.0에서 처음 등장한 것으로 var로 선언된 변수는 닷넷에서 제공하는 대부분의 형식 사용할 수 있다. var 형식은 기존에 닷넷에서 존재하는 형식에서 사용하기 보다는 익명 형식(anonymous type)을 위해 탄생했다고 봐도 될 것이다. 익명 형식은 아래 코드처럼 타입의 이름을 지정하지 않고 사용 시점에 바로 바로 선언하여 객체로 사용할 수 있다. 하지만 기존 언어적 특성에서는 모든 타입은 명시적으로 선언되어야만 사용할 수 있었다. 이러한 점을 해결하고자 var 형식이 나오게 되었다. var 형식은 최초 초기화되어 타입이 정해진 이후에는 타입을 변경할 수 없다. 그러므로 null로는 초기화 할 수 없다. 반드시 선언 시점에 특정 타입으로 초기화 되어야 한다. var 타입은 선언 시점에서 타입을 추정하기 때문에 IDE에서 해당 타입에 맞는 인텔리센스가 완벽하게 지원 된다.
var items = new[] { new {Title = "A", StartDate = "20121210", EndDate = "20121231"}, new {Title = "B", StartDate = "20121201", EndDate = "20121231"}, new {Title = "C", StartDate = "20121207", EndDate = "20121208"}, new {Title = "D", StartDate = "20121217", EndDate = "20121231"}, new {Title = "E", StartDate = "20121203", EndDate = "20121210"} };
|
[익명 형식(anonymous type) 선언 예]
[var 타입으로 선언시 null로 초기화 할 수 없다]
var 형식은 다음과 같은 특징을 가지고 있다.
- 사용 가능 한 type
- built-in type
- anonymous type
- user-defined type
- type defined in the .NET FCL
- 선언시 유의사항
- var temp; //초기화기 되지 않음
- var temp = null; //특정한 type을 가져야 함.
- 메소드의 파라미터로 사용할 수 없음
dynamic
C# 4.0에 오면서 상호 운영성(interop)에 대한 부분이 많이 강조가 되었다. C#과 VB, COM등 과의 연동 등 기존의 복잡함을 dynamic 타입을 통해서 개발 시점에 많이 간결하게 처리가 가능하다. dynamic 타입은 컴파일 시점에 타입에 대한 확인을 하지 않기 때문에 개발 시점에서 인텔리센스는 동작하지 않는다.
var vs. dynamic vs. object 무엇이 다른가?
- ( var, dynamic) vs. object
- 공통점 : 선언 시점에 다양한 타입을 지정할 수 있다.
- 차이점 : var, dynamic 타입은 선언된 원본 형식을 유지한다. 하지만 object 으로 선언을 하게 되면 원본의 특성을 읽어 버리게 된다. object로 선언 되었다가 원본 형식으로 바꾸기 위해서는 반드시 형변환 처리가 필요하다. 아래 각 타입으로 선언시 인텔리센스 화면을 보면 그 차이를 좀더 확실히 확인이 가능하다.
- var vs. dynamic
- 공통점 : 닷넷에서 지원하는 대부분의 타입을 선언할 수 있으며, 원본 타입의 특정을 가지고 있다.
- 차이점 : 두 타입에서 가장 큰 차이점은 타입이 확정 되는 시점이다. var 타입은 컴파일 시점에 이미 타입을 추정하여 확정을 하게 된다. 하지만 dynamic 타입은 런타임 시점이 타입이 확정되게 된다. 그러므로 dynamic 형식으로 사용하는 값이 올바르지 않은 타입이 지정이 되더라도 컴파일 시점에서는 모두 by-pass 되며, 런타임 시점에 예외를 발생하게 된다. 이점을 유의 해야 된다.
var
dynamic
형식의 확정 시점
Compile time
Runtime
바인딩(binding) 방식
Static Binding
Late Binding
[object로 선언을 하면 원본의 특성을 상실하게 된다. 선언된 값은 object 자체인 것이다.]
[타입을 추정하여 원본의 특성을 유지한다. 각 타입에 맞는 인텔리센스가 작동하는 것을 볼 수 있다.]
[원본의 특성을 유지 하지만, 컴파일 시점에서는 확인을 할 수 없기 때문에 인텔리센스가 동작하지 않는다.]
결론적으로 var 선언과 명시적 타입 선언의 차이점은 없다. 단, var 이외의 방식은 사용 방법에 따라 성능에 영향을 미칠 수 있으므로, 명확한 목적에 따라 사용해야 한다.
[출처] C#의 다양한 타입(type) 선언 : var vs. dynamic vs. object|작성자 SuYoung Kim
댓글 0
조회수 39,687등록된 댓글이 없습니다.