ãã£ãŒãããã¯çµæ
CïŒãš* nixã«ã€ããŠ
å€ãã¯ãnixã·ã¹ãã ã§CïŒãèšè¿°ããæ¹æ³ã«èå³ããããŸããã åéãå©ããããšæããŸãã Monoãããžã§ã¯ãããããŸããWikipediaãã次ã®ããšãããããŸãã
Monoã¯ãããªãŒãœãããŠã§ã¢ã«åºã¥ãã.NETã·ã¹ãã ã®æ¬æ Œçãªå®è£ ãäœæãããããžã§ã¯ãã§ãã
Monoã«ã¯ãCïŒã³ã³ãã€ã©ãmcsã.NETã©ã³ã¿ã€ã ã¢ãïŒJITãµããŒãããïŒããã³ãã³ãïŒJITãµããŒããªãïŒããããã¬ãŒãããã³ADO.NETããã³ASP.NETã®å®è£ ãå«ãå€æ°ã®ã©ã€ãã©ãªãå«ãŸããŸãã ãã®ãããžã§ã¯ãã¯ã.NETãã©ãããã©ãŒã äžã®GTK +ã°ã©ãã£ãã¯ã·ã¹ãã ã®ãã€ã³ãã£ã³ã°ãéçºããŸãã
monoã©ã³ã¿ã€ã ã¯ãCïŒãVisual Basic .NETãJavaãBooãNemerleãPythonãJavaScriptãPHPãããã³Object Pascalã§èšè¿°ãããã¢ãžã¥ãŒã«ãå®è¡ã§ããŸãïŒ.Net / Monoç°å¢ã«ã³ã³ãã€ã©ãŒãããå ŽåïŒã CãAda 2005ãããã³Eiffelã®ãµããŒããäºå®ãããŠããŸãã
次ã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ã¢ãã©ã«å®è£ ãååšããŸãïŒGNU / LinuxãSolarisãMac OS XãMicrosoft Windowsãããã³Unixã
ããã¯ãã»ãšãã©ãã¹ãŠã®CïŒOSã§ç°¡åã«ããã°ã©ã ã§ããããšã瀺ããŠããŸãã Mono Projectã®ææ°ãªãªãŒã¹ã¯2.2ã§ãã Mono Project-ããã§ã¯ãææ°ããŒãžã§ã³ãããŠã³ããŒãããããããã¥ã¡ã³ããåç §ãããã§ããŸãã
ããã«è¯ããã¥ãŒã¹ããããŸãã MonoéçºããŒã ã«ã¯ã MonoDevelopãšããè£å©ãããžã§ã¯ãããããŸãã ããã¯ãCïŒããã³ASP.NETçšã®ç¡æã®IDEã§ãã * nixã·ã¹ãã ã§ã®è¿ éãã€è¿ éãªéçºã«å¿ èŠãªãã¹ãŠã®æ©èœããµããŒãããŸãã
ç§ã®é£äºº-ç§ã®å人
RubyãPythonãªã©ã®ããã°ã©ãã³ã°èšèªã«é¢ããèšäºãè¿æã§æžãããŠããã®ã§ãç§ãã¡ã¯é£äººãšåéã«ãªãã¹ãã§ãã
IronRuby
IronRubyã¯ãMicrosoft .NETãã©ãããã©ãŒã ã§ã®Rubyããã°ã©ãã³ã°èšèªã®å®è£ ã§ãã ã€ã³ã¿ãŒããªã¿ãŒã¯ãCLR 2.0ã§å®è¡ãããã©ã€ãã©ãªã§ããDynamic Language Runtimeã«åºã¥ããŠããŸãããã®ã©ã€ãã©ãªã¯ããšããããåçåä»ããšåçã¡ãœããå®çŸ©ãæäŸããŸãã
IronPython
IronPython -Microsoft .NETãŸãã¯Monoãã©ãããã©ãŒã çšã«èšèšãããPythonèšèªã®äž»èŠãªå®è£ ã®1ã€ã å®å šã«CïŒã§èšè¿°ãããŠãããã³ã³ãã€ã©ãŒåã®ã³ã³ãã€ã©ãŒã§ãã
IronPythonã¯.NETã¿ã€ãã䜿çšã§ããŸãã IronPythonã·ã¹ãã ããã¹ãããããIronPythonã³ãŒããäºåã«çµã¿ç«ãŠãããšã«ããã.NETã³ãŒãããIronPythonã³ãŒãã䜿çšããããšãã§ããŸãã
IronPython
èªãã§ïŒ
æ¬ããã ããçšã®CïŒã¯ç§ã®ãã€ãã£ãã«ãªããŸããã èè ïŒãµã€ã¢ã³ã»ããã³ãœã³ããªãŒã«ãã£ãŒã»ã³ãŒã³ãºããžã§ã€ã»ã°ãªã³ãããŒãã³ã»ããŒãã€ãªã©ç§ã¯åœŒå¥³ããããã«å§ããŸããããããã°ã©ãã³ã°ã®çµéšããã£ãã®ã§ããããæã¡ã§ãªããã°ã CïŒèè ïŒã«ãŒãªãŒã»ã¯ããœã³ãèªãããšããå§ãããŸãã
CïŒã«ãŒãªãŒã¯ããœã³ãæçš¿ã
CïŒå°é家åãã èè ïŒãµã€ã¢ã³ã»ããã³ãœã³ä»
ç¶ããŸããã...
CïŒããŒã¿å
ãŠã£ãããã£ã¢
ããŒã¿åïŒããŒã¿åãšããçšèªããããŸãïŒã¯ãããã°ã©ãã³ã°çè«ã®åºæ¬æŠå¿µã§ãã ããŒã¿åã¯ã1ïŒå€ã®ã»ããã2ïŒãã®ãããªå€ã«é©çšã§ããæäœã®ã»ããããããŠãããã3ïŒå€ã®æ ŒçŽãå®è£ ããŠæäœãå®è¡ããæ¹æ³ãå®çŸ©ããŸãã ããã°ã©ã ãåäœããããŒã¿ã¯ç¹å®ã®ã¿ã€ãã§ãã
CïŒã¯åŒ·ãåä»ããããèšèªã§ãã 䜿çšãããšãã¯ãäœæããåãªããžã§ã¯ãã®ã¿ã€ãïŒæŽæ°ãæµ®åå°æ°ç¹æ°ãæååããŠã£ã³ããŠããã¿ã³ãªã©ïŒã宣èšããå¿ èŠããããã³ã³ãã€ã©ãŒã¯å€æ°ã«å€ã®ã¿ãå²ãåœãŠãããšã«é¢é£ãããšã©ãŒãåé¿ããã®ã«åœ¹ç«ã¡ãŸããããã«äžèŽããã¿ã€ãã ãªããžã§ã¯ãã®åã¯ãã³ã³ãã€ã©ã«ãªããžã§ã¯ãã®ãµã€ãºïŒããšãã°ãintåã®ãªããžã§ã¯ããã¡ã¢ãªå ã§4ãã€ããå ããïŒãšãã®ããããã£ïŒããšãã°ããã©ãŒã ã衚瀺ããã³é衚瀺ã«ããããšãã§ãããªã©ïŒãäŒããŸãã
ãããã®ç®çãããããç解ããããã«ãäŸãæããŸãã ã¿ã€ãã¯åãçš®é¡ã§ãã ããšãã°ãããŸããŸãªãªã³ãŽã ããåçš®ã®ãªã³ãŽã¯å€§ãããéãå«ãã§ããŠèµ€ããå¥ã®åçš®ã®ãªã³ãŽã¯å°ãããŠãã¿ãè²ã«ãªãããšããããŸã=ïŒ
CïŒã¯ãŸããåãä»ã®2ã€ã®ã«ããŽãªã«åå²ããŸãïŒ æ¬¡å ãšåç § ã
çµã¿èŸŒã¿å
CïŒèšèªã¯ãããã°ã©ããŒã«åºç¯å²ã®çµã¿èŸŒã¿åãæäŸããŸãã ãããã¯ãã¹ãŠCLSïŒCommon Language SpecificationïŒã«æºæ ããŠãããããCïŒã§äœæããããªããžã§ã¯ãã¯ã.NETããµããŒãããä»ã®ããã°ã©ãã³ã°èšèªã§äœæããããªããžã§ã¯ããšäžç·ã«æ£åžžã«äœ¿çšã§ããŸãã åã¿ã€ãã«ã¯å³å¯ã«å®çŸ©ããããµã€ãºããããå€æŽããããšã¯ã§ããŸããã
çµã¿èŸŒã¿åã®ããŒãã«ãèŠãŠã¿ãŸãããïŒ
æåã®åã«ã¯ãã¿ã€ãã®ååãå€ã®ç¯å²ïŒæ°ããæ°ãŸã§ïŒãæåŸã«ãµã€ãºãå«ãŸããŸãã
ã€ã³ã©ã€ã³åã®å€æ
ããã¿ã€ãã®ãªããžã§ã¯ãã¯ãæé»çãŸãã¯æ瀺çã«å¥ã®ã¿ã€ãã®ãªããžã§ã¯ãã«å€æã§ããŸãã æé»çãªå€æã¯èªåçã«è¡ãããã³ã³ãã€ã©ãŒã¯ãŠãŒã¶ãŒã®ä»£ããã«ãããè¡ããŸãã å€ãç°ãªãåã«ããã£ã¹ãããããšãæ瀺çãªå€æãçºçããŸãã æé»çãªå€æã«ãããããŒã¿ã倱ãããªãããã«ããªããŸãã ããšãã°ãshortïŒ2ãã€ãïŒããintïŒ4ãã€ãïŒã«æé»çã«ãã£ã¹ãã§ããŸãã
ç¹°ãè¿ããŸãããå°ããªäŸã§ãã ãã±ããšã«ãããçšæããŸãããã =ïŒã«ãããããã±ãã«æ°Žã泚ããšãæé»ã®å€æããåŸããããã±ãããã«ããã«å ¥ãããšãæ瀺çã«ãã®ã¿ãåŸãããŸãã ããã¯ã©ã®ããã«å¯èœã§ããïŒ æ®ãã®æ°Žã¯ãã¹ãŠæ³šãåºããŠããŸãã
å€ãçããŠããintã«å€æãããšãã«å€±ãããããšã¯ãããŸããã
short x = 1; int = ; //
short x = 1; int = ; //
éå€æãè¡ããšããã¡ãããæ å ±ã倱ãå¯èœæ§ããããŸãã intã®å€ã32.767ãã倧ããå Žåãå€æäžã«åãæšãŠãããŸãã ã³ã³ãã€ã©ã¯ãintããshortãžã®æé»çãªå€æãå®è¡ããŸããã
- çã x;
- int y = 5;
- x = y; //ã³ã³ãã€ã«ããŸãã
ãã£ã¹ãæŒç®åã䜿çšããŠæ瀺çãªå€æãå®è¡ããå¿ èŠããããŸãã
- çã x;
- int yã¯5ã§ãã
- x =ïŒ short ïŒy; //ãããŠä»ããã¹ãŠãOKã§ã
åç §ã«ããã¿ã€ã
ã¿ã€ããªããžã§ã¯ã
CïŒã§ã¯ãåãªããžã§ã¯ãã¯ãã¹ãŠã®åã®å ã®ç¥å åã§ãã ãªããžã§ã¯ããªã³ã¯ã䜿çšããŠãä»»æã®ãªããžã§ã¯ãã«ãã€ã³ãã§ããŸãã ãŸããã¿ã€ããäžæãªãªããžã§ã¯ãã§ã³ãŒãã䜿çšããå¿ èŠãããå Žåã®ãªãã¬ã¯ã·ã§ã³ã«ã圹ç«ã¡ãŸãã
ãªããžã§ã¯ãã¯ãããã€ãã®åªããã¡ãœãããæäŸããŸãã EqualsïŒïŒ ã GetHashCodeïŒïŒ ã GetTypeïŒïŒããã³ToStringïŒïŒ ãããã®ã¡ãœããã¯ã©ã®ãªããžã§ã¯ãã§ã䜿çšã§ããåŸã§èª¬æããŸãã
ã¿ã€ãæåå
CïŒã«ã¯ç¬èªã®ã¿ã€ãæååããããŸãã ãããã£ãŠãã³ããŒãããŒãžãªã©ã®æäœã¯å³åº§ã«çºçããŸãã
- æåå s1 = "Helloã" ;
- æåå s2 = "Habra" ;
- æåå s3 = "HabrïŒ" ;
- æåå s4 = s2 + s1 + s3;
- Console .WriteLineïŒs4ïŒ; // =>ããã«ã¡ã¯ãHabrahabrïŒ
å€ã«ããåã®ã¹ã¿ã€ã«ã§å²ãåœãŠãè¡ãããŸãããSystem.Stringåã¯åç §ã«ããåã§ãã è¡ã«æ»ããŸãïŒ
å€æ°
å€æ°ã¯ãç¹å®ã®ã¿ã€ãã®ãªããžã§ã¯ãã®ã¡ã¢ãªå ã®å Žæã§ãã äžèšã®äŸã§ã¯ãxãšyã¯å€æ°ã§ãã å€æ°ã«ã¯ãåæåã«äœ¿çšããå€ãèšå®ã§ããŸãããŸãã¯ããããã®å€ãããã°ã©ã ã§å€æŽã§ããŸãã
å€æ°ãäœæããã«ã¯ãå€æ°ã®ã¿ã€ããæå®ããŠããããã®ã¿ã€ãã«ååãä»ããå¿ èŠããããŸãã 宣èšäžã«å€æ°ãåæåããããããã°ã©ã å®è¡äžã«å€æ°ã«æ°ããå€ãå²ãåœãŠãããšãã§ããŸãã 以äžã«ãæåã®ã±ãŒã¹ã§ã¯åæåã䜿çšããŠå€æ°ã«å€ãå²ãåœãŠããµã³ãã«ããã°ã©ã ã瀺ããŸãã2çªç®ã®ã±ãŒã¹ã§ã¯ãã=ãæŒç®åã䜿çšããŠå€æ°ã«å€ã®å²ãåœãŠã䜿çšããŸãã
- ã¯ã©ã¹å€æ°
- {
- éç ãã€ãã¡ã€ã³ïŒïŒ
- {
- int myInt = 10;
- ã·ã¹ãã Console .WriteLineïŒ "åæåãããå€æ°myIntïŒ" + myIntïŒ;
- myInt = 5;
- ã·ã¹ãã Console .WriteLineïŒ "å€ãå²ãåœãŠãåŸã®å€æ°myIntïŒ" + myIntïŒ;
- Console .ReadLineïŒïŒ;
- }
- }
ãã®ããã°ã©ã ã®çµæã¯æ¬¡ã®ãšããã§ãã
åæåãããå€æ°mylntïŒ10
å€ãå²ãåœãŠãåŸã®myIntïŒ5
è¡ã¯æ¬¡ã®ãšããã§ãã
int myInt = 10;
mylntå€æ°ã®å®£èšãšåæåãæå³ããŸãã è¡ïŒ
myInt = 5;
mylntã5ã«èšå®ããããšãæå³ããŸãã
CïŒã§ã¯å€ã®å®çŸ©ãå¿ èŠã§ããã€ãŸããå€æ°ã¯äœ¿çšããåã«åæåããå¿ èŠããããŸãã ãã®ã«ãŒã«ããã¹ãããã«ã¯ã次ã®äŸãæ€èšããŠãã ããã
- ã¯ã©ã¹å€æ°
- {
- éç ãã€ãã¡ã€ã³ïŒïŒ
- {
- int myInt;
- ã·ã¹ãã Console .WriteLineïŒ "åæåãããŠããªãå€æ°myIntïŒ" + myIntïŒ;
- myInt = 5;
- ã·ã¹ãã Console .WriteLineïŒ "å€æ°myIntãå²ãåœãŠãåŸïŒ" + myIntïŒ;
- }
- }
ãã®äŸãã³ã³ãã€ã«ããããšãããšãã³ã³ãã€ã©ã¯æ¬¡ã®ãšã©ãŒã¡ãã»ãŒãžã衚瀺ããŸãã
ãšã©ãŒCS3165ïŒæªå²ãåœãŠã®ããŒã«ã«å€æ° 'mylnt'ã®äœ¿çš
CïŒã§åæåãããŠããªãå€æ°ã䜿çšããããšã¯ã§ããŸããïŒ
ãããšãè©ŠããŸããïŒ
ããã§ã¯ãå°ããªããã°ã©ã ãæžããŸãããã 圌女ã¯äœãããŸããïŒ äžäººã«ã€ãçãé¢ä¿æžé¡ã衚瀺ããïŒ
- ã·ã¹ãã ã䜿çšã㊠;
- ã¯ã©ã¹ãã¡ãŒã¹ã
- {
- æååã®åœãéœåžã
- æååå= "Vasya Pupkin" ;
- int oldãnum;
- å€ã= 12;
- num = 666;
- åœ= "ãã·ã¢" ;
- city = "Our" ;
- Console .WriteLineïŒ "NameïŒ" + nameïŒ;
- Console .WriteLineïŒ "AgeïŒ" + oldïŒ;
- Console .WriteLineïŒ "LocationïŒ" +åœ+éœåžïŒ;
- Console .WriteLineïŒ "/ n / tSerial numberïŒ" + numïŒ;
- Console .ReadLineïŒïŒ;
- }
æåã«å€æ°ã®å®£èšãšåæåããããŸãã 以äžã¯ããããã®å€æŽã®çµè«ã§ãã 17è¡ç®ã§ã2ã€ã®æ°ãããã£ã©ã¯ã¿ãŒã«åºããããŸãã ãããã¯/ nãš/ tã§ãã 1ã€ç®ã¯ãã©ã±ãããæ°ããè¡ã«å€æããããã«äœ¿çšããã2ã€ç®ã¯ã¿ãã§ãã 以äžã¯ã䜿çšã§ããæåããŒãã«ã§ãã
18è¡ç®ã«Console.ReadLineïŒïŒãè¿œå ããŸãã-ããã¯ãããã°ã©ã ã®èµ·ååŸã«ã³ã³ãœãŒã«ãéããªãããã«ããããã§ãã
ä»æ¥ã¯ä»¥äžã§ãã
PS誰ãã®ããã«ãããããèå³æ·±ããªã³ã¯ãèŠã€ããŸããã
ãªã¿ã¯ã®CïŒã ïŒMSDNïŒ