fbpx
วิกิพีเดีย

ภาษาซีชาร์ป

ภาษาซีชาร์ป (C# Programming Language) เป็นภาษาโปรแกรมแบบหลายโมเดล ที่ใช้ระบบชนิดข้อมูลแบบรัดกุม (strong typing) และสนับสนุนการเขียนโปรแกรมเชิงคำสั่ง การเขียนโปรแกรมเชิงประกาศ การเขียนโปรแกรมเชิงฟังก์ชัน การเขียนโปรแกรมเชิงกระบวนการ การเขียนโปรแกรมเชิงวัตถุ (แบบคลาส) และการเขียนโปรแกรมเชิงส่วนประกอบ พัฒนาเริ่มแรกโดยบริษัทไมโครซอฟท์เพื่อทำงานบนดอตเน็ตเฟรมเวิร์ก โดยมีแอนเดอร์ เฮลส์เบิร์ก (Anders Hejlsberg) เป็นหัวหน้าโครงการ และมีรากฐานมาจากภาษาซีพลัสพลัสและภาษาอื่นๆ (โดยเฉพาะภาษาเดลไฟและจาวา) โดยมีจุดมุ่งหมายให้เป็นภาษาสมัยใหม่ที่ไม่ซับซ้อน ใช้งานได้ทั่วไป (general-purpose) และเป็นเชิงวัตถุเป็นหลัก

เครื่องหมาย

ปัจจุบันภาษาซีชาร์ปมีการรับรองให้เป็นมาตรฐานโดยเอ็กมาอินเตอร์เนชันแนล (Ecma International) และองค์การระหว่างประเทศว่าด้วยการมาตรฐาน (ISO) และมีรุ่นล่าสุดคือ C# 9.0 ที่ออกมาในปี พ.ศ. 2563

ตัวอย่าง

ตัวอย่างต่อไปนี้ คือตัวอย่างโปรแกรม Hello world ใน C#:

public class ExampleClass { public static void Main() { System.Console.WriteLine("Hello, world!"); } } 

ผลของการทำงานคือมีการแสดงคำว่า Hello, world! ในหน้าต่างคอนโซล โดยในแต่ละบรรทัดมีความหมายดังนี้:

public class ExampleClass 

บรรทัดนี้คือการประกาศคลาส โดย public หมายถึงวัตถุที่สร้างในโครงการ (project) อื่น ๆ สามารถเข้าใช้งานคลาสนี้ได้ ไม่จำกัด. ข้อมูลต่างๆ ที่อยู่ผ่านใต้หน่วยของบรรทัดนี้ จะใช้ในการทำงานของคลาสนี้

public static void Main() 

บรรทัดนี้เป็นจุดที่ใช้ในการเริ่มการทำงานของโปรแกรม เมื่อโปรแกรมทำงาน โดยสามารถเรียกใช้จากโปรแกรมอื่นได้โดยการใช้ไวยากรณ์ ExampleClass.Main(). (public static void เป็นส่วนที่ใช้ในการทำงาน ซึ่งต้องเรียนรู้ในการเขียนขั้นสูง)

System.Console.WriteLine("Hello, world!"); 

ในบรรทัดนี้ เป็นการทำงาน เพื่อแสดงผลออกมา Console คือโปรแกรมระบบ, ซึ่งก็คือ โปรแกรมระบบแบบสั่งคำสั่งที่ละบรรทัด (เช่น DOS) ที่สามารถรับข้อมูลและแสดงผลเป็นข้อความได้. จากที่เราเขียนโปรแกรมจะทำการเรียก Console โดยใช้คำสั่ง WriteLine, ซึ่งทำให้สามารถส่งค่าข้อความออกมาแสดงผลได้

มาตรฐาน

ไมโครซอฟท์ส่งมาตรฐานภาษาซีชาร์ปให้กับ Ecma และได้รับการยอมรับเป็นมาตรฐาน ECMA ในเดือนธันวาคม ค.ศ. 2001 ในชื่อว่า ECMA-334 C# Language Specification ใน ค.ศ. 2003 ภาษาซีชาร์ปได้รับการยอมรับเป็นมาตรฐาน ISO (ISO/IEC 23270).

มาตรฐาน ISO/IEC 23270:2003 ระบุรูปแบบ และกำหนดการแปล (ตีความ) โปรแกรมที่เขียนด้วยภาษาซีชาร์ป. โดยตัวมาตรฐานได้ระบุ:

  • รูปแบบการนำเสนอ (the representation of C# programs)
  • ไวยากรณ์ (the syntax and constraints of the C# language)
  • กฎการตีความสำหรับแปลโปรแกรมภาษาซีชาร์ป (the semantic rules for interpreting C# programs)
  • ข้อห้าม และข้อจำกัด ของเครื่องมือที่สร้างตามข้อกำหนดของซีชาร์ป (the restrictions and limits imposed by a conforming implementation of C#)

ISO/IEC 23270:2003 ไม่ได้ระบุ:

  • กลไกในการแปลงโปรแกรมภาษาซีชาร์ป เพื่อใช้ในระบบประมวลผลข้อมูล (the mechanism by which C# programs are transformed for use by a data-processing system)
  • กลไกในการเรียกให้โปรแกรมภาษาซีชาร์ปทำงาน เพื่อใช้ในระบบประมวลผลข้อมูล (the mechanism by which C# applications are invoked for use by a data-processing system)
  • กลไกในการแปลงข้อมูลเข้า เพื่อใช้กับโปรแกรมภาษาซีชาร์ป (the mechanism by which input data are transformed for use by a C# application)
  • กลไกในการแปลงข้อมูลออก หลังจากถูกประมวลผลโดยโปรแกรมภาษาซีชาร์ป (the mechanism by which output data are transformed after being produced by a C# application)
  • the size or complexity of a program and its data that will exceed the capacity of any specific data-processing system or the capacity of a particular processor;
  • all minimal requirements of a data-processing system that is capable of supporting a conforming implementation.

นอกจากนี้ตัวมาตรฐานไม่ได้กล่าวถึงโครงสร้างข้อมูล และตัวไลบรารีกลางของ .NET Framework ซึ่งเป็นหัวใจสำคัญของการเขียนโปรแกรมด้วยภาษาซีชาร์ปเลย

อ้างอิง

  • ISO/IEC 23270:2003 Information technology — C# Language Specification

แหล่งข้อมูลอื่น

  • Microsoft Developer Network - Visual C#
  • เทคนิคการเขียนโปรแกรมขั้นสูง C#
  • บทความ (ภาษาไทย) สอนภาษา C#
  • บทความ (ภาษาไทย) สอนภาษา C# และอื่น ๆ ที่เกี่ยวข้อง

ภาษาซ, ชาร, เน, อหาในบทความน, าสม, โปรดปร, บปร, งข, อม, ลให, เป, นไปตามเหต, การณ, จจ, นหร, อล, าส, หน, าอภ, ปรายประกอบบทความน, อาจขยายความได, โดยการแปลบทความท, ตรงก, นในภาษาอ, งกฤษ, คล, กท, ขยาย, เพ, อศ, กษาแนวทางการแปลค, ณสามารถด, การแปลด, วยคอมพ, วเตอร, จากบ. enuxhainbthkhwamnilasmy oprdprbprungkhxmulihepniptamehtukarnpccubnhruxlasud duhnaxphiprayprakxbbthkhwamnixackhyaykhwamidodykaraeplbthkhwamthitrngkninphasaxngkvs khlikthi khyay ephuxsuksaaenwthangkaraeplkhunsamarthdukaraepldwykhxmphiwetxrcakbthkhwaminphasaxngkvs ekhruxngmuxchwyaeplxyang diphaexl hrux kuekilthranselth epncuderimtnthidisahrbkaraepl xyangirktam phuaeplcatxngtrwcsxbkhxphidphladcakkaraepldwykhxmphiwetxraelayunynwakaraeplnnthuktxng erakhxptiesthenuxhathikhdlxkcakekhruxngmuxaeplthiimmikartrwcthankxnephyaephr krunaxyaaeplswnkhxngkhxkhwamthiduaelwechuxthuximidhruxmikhunphaphta thaepnipid oprdchwyyunyndwykartrwcsxbaehlngxangxingthipraktinbthkhwamphasann oprdrabuiwinkhwamyxkaraekikhwakhunaeplenuxhamacakphasaid khunkhwrephimaemaebb Translated en C Sharp programming language iwinhnaphudkhuy sahrbkhaaenanaaelaaenwthangephimetim oprdsuksaidthi wikiphiediy karaeplphasasicharp C Programming Language epnphasaopraekrmaebbhlayomedl thiichrabbchnidkhxmulaebbrdkum strong typing aelasnbsnunkarekhiynopraekrmechingkhasng karekhiynopraekrmechingprakas karekhiynopraekrmechingfngkchn karekhiynopraekrmechingkrabwnkar karekhiynopraekrmechingwtthu aebbkhlas aelakarekhiynopraekrmechingswnprakxb phthnaerimaerkodybristhimokhrsxfthephuxthanganbndxtentefrmewirk odymiaexnedxr ehlsebirk Anders Hejlsberg epnhwhnaokhrngkar aelamirakthanmacakphasasiphlsphlsaelaphasaxun odyechphaaphasaedlifaelacawa odymicudmunghmayihepnphasasmyihmthiimsbsxn ichnganidthwip general purpose aelaepnechingwtthuepnhlkekhruxnghmay pccubnphasasicharpmikarrbrxngihepnmatrthanodyexkmaxinetxrenchnaenl Ecma International aelaxngkhkarrahwangpraethswadwykarmatrthan ISO aelamirunlasudkhux C 9 0 thixxkmainpi ph s 2563 enuxha 1 twxyang 2 matrthan 3 xangxing 4 aehlngkhxmulxuntwxyang aekikhtwxyangtxipni khuxtwxyangopraekrm Hello world in C public class ExampleClass public static void Main System Console WriteLine Hello world phlkhxngkarthangankhuxmikaraesdngkhawa Hello world inhnatangkhxnosl odyinaetlabrrthdmikhwamhmaydngni public class ExampleClass brrthdnikhuxkarprakaskhlas ody public hmaythungwtthuthisranginokhrngkar project xun samarthekhaichngankhlasniid imcakd khxmultang thixyuphanithnwykhxngbrrthdni caichinkarthangankhxngkhlasni public static void Main brrthdniepncudthiichinkarerimkarthangankhxngopraekrm emuxopraekrmthangan odysamartheriykichcakopraekrmxunidodykarichiwyakrn ExampleClass Main public static void epnswnthiichinkarthangan sungtxngeriynruinkarekhiynkhnsung System Console WriteLine Hello world inbrrthdni epnkarthangan ephuxaesdngphlxxkma Console khuxopraekrmrabb sungkkhux opraekrmrabbaebbsngkhasngthilabrrthd echn DOS thisamarthrbkhxmulaelaaesdngphlepnkhxkhwamid cakthieraekhiynopraekrmcathakareriyk Console odyichkhasng WriteLine sungthaihsamarthsngkhakhxkhwamxxkmaaesdngphlidmatrthan aekikhimokhrsxfthsngmatrthanphasasicharpihkb Ecma aelaidrbkaryxmrbepnmatrthan ECMA ineduxnthnwakhm kh s 2001 inchuxwa ECMA 334 C Language Specification in kh s 2003 phasasicharpidrbkaryxmrbepnmatrthan ISO ISO IEC 23270 matrthan ISO IEC 23270 2003 raburupaebb aelakahndkaraepl tikhwam opraekrmthiekhiyndwyphasasicharp odytwmatrthanidrabu rupaebbkarnaesnx the representation of C programs iwyakrn the syntax and constraints of the C language kdkartikhwamsahrbaeplopraekrmphasasicharp the semantic rules for interpreting C programs khxham aelakhxcakd khxngekhruxngmuxthisrangtamkhxkahndkhxngsicharp the restrictions and limits imposed by a conforming implementation of C ISO IEC 23270 2003 imidrabu klikinkaraeplngopraekrmphasasicharp ephuxichinrabbpramwlphlkhxmul the mechanism by which C programs are transformed for use by a data processing system klikinkareriykihopraekrmphasasicharpthangan ephuxichinrabbpramwlphlkhxmul the mechanism by which C applications are invoked for use by a data processing system klikinkaraeplngkhxmulekha ephuxichkbopraekrmphasasicharp the mechanism by which input data are transformed for use by a C application klikinkaraeplngkhxmulxxk hlngcakthukpramwlphlodyopraekrmphasasicharp the mechanism by which output data are transformed after being produced by a C application the size or complexity of a program and its data that will exceed the capacity of any specific data processing system or the capacity of a particular processor all minimal requirements of a data processing system that is capable of supporting a conforming implementation nxkcaknitwmatrthanimidklawthungokhrngsrangkhxmul aelatwilbrariklangkhxng NET Framework sungepnhwicsakhykhxngkarekhiynopraekrmdwyphasasicharpelyxangxing aekikhISO IEC 23270 2003 Information technology C Language Specificationaehlngkhxmulxun aekikhMicrosoft Developer Network Visual C ethkhnikhkarekhiynopraekrmkhnsung C bthkhwam phasaithy sxnphasa C bthkhwam phasaithy sxnphasa C aelaxun thiekiywkhxng bthkhwamekiywkbkarekhiynopraekrm hrux phasaopraekrmniyngepnokhrng khunsamarthchwywikiphiediyidodyephimkhxmulekhathungcak https th wikipedia org w index php title phasasicharp amp oldid 9190864, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม