Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Identifiers ใน C# (ตัวระบุชื่อ)

Identifier คือชื่อสำหรับ Class, Variable, Function หรือ User-defined Items

กฎการตั้งชื่อ

  • ขึ้นต้นตัวอักษร ตามด้วย ตัวอักษร/ตัวเลข/Underscore (_) ตัวแรกไม่ใช่ตัวเลข
  • ไม่得有 Space หรือ Symbol: ? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / \ (Underscore ใช้ได้)
  • ห้ามเป็น C# Keyword

ตัวอย่าง Identifiers

Class Names

class Calculation
class Demo

Valid Function Names

void display()
void getMarks()

Variable Names

int a; int marks; int rank; double res_marks;