Algorithm


In C#, keywords are reserved words that have special meanings and cannot be used as identifiers (names for variables, classes, methods, etc.). Identifiers, on the other hand, are names given to various program elements such as variables, classes, methods, etc. It's important to choose meaningful and descriptive identifiers for better code readability.

Here are some common C# keywords:

  1. Abstract: Used to declare abstract classes and methods.
  2. As: Used for type casting.
  3. Base: Refers to the base class in an inheritance hierarchy.
  4. Bool: Represents a Boolean value (true or false).
  5. Break: Exits from a loop or a switch statement.
  6. Byte: Represents an 8-bit unsigned integer.
  7. Case: Used in switch statements to define different cases.
  8. Catch: Catches exceptions in a try-catch block.
  9. Char: Represents a 16-bit Unicode character.
  10. Class: Defines a class.
  11. Const: Declares a constant field or a constant local.
  12. Continue: Skips the rest of a loop and continues with the next iteration.
  13. Decimal: Represents a 128-bit decimal value.
  14. Default: Used in a switch statement to provide a default case.
  15. Delegate: Defines a delegate.
  16. Do: Starts a do-while loop.
  17. Double: Represents a double-precision floating-point number.
  18. Else: Used in an if-else statement.
  19. Enum: Declares an enumeration.
  20. Event: Declares an event.
  21. Explicit: Specifies explicit implementation of an interface member.
  22. Extern: Specifies that a method is implemented externally.
  23. False: Represents the Boolean value false.
  24. Finally: Defines a block of code that is always executed in a try-catch-finally statement.
  25. Fixed: Declares a fixed-size array.
  26. Float: Represents a single-precision floating-point number.
  27. For: Starts a for loop.
  28. Foreach: Iterates over elements in a collection.
  29. Goto: Transfers control to a labeled statement.
  30. If: Used to make a decision in a conditional statement.
  31. Implicit: Specifies implicit implementation of an interface member.
  32. In: Specifies that a parameter is passed by reference.
  33. Int: Represents a 32-bit signed integer.
  34. Interface: Declares an interface.
  35. Internal: Specifies that a member is accessible within its assembly.
  36. Is: Checks if an object is of a certain type.
  37. Lock: Acquires the mutual-exclusion lock for a given object.
  38. Long: Represents a 64-bit signed integer.
  39. Namespace: Declares a namespace.
  40. New: Creates an object or initializes a new instance of a type.
  41. Null: Represents a null reference.
  42. Object: Represents a base class for all types.
  43. Operator: Declares an operator.
  44. Out: Specifies that a parameter is passed by reference.
  45. Override: Provides a new implementation for a base class member.
  46. Params: Specifies that a method parameter takes a variable number of arguments.
  47. Private: Specifies that a member is accessible only within its declaring type.
  48. Protected: Specifies that a member is accessible within its declaring type and its derived types.
  49. Public: Specifies that a member is accessible from any assembly.
  50. Readonly: Specifies that a field can only be assigned in its declaration or in the constructor.

These are just a few examples, and there are more keywords in C#. It's important to note that some keywords may have additional meanings or functionalities depending on the context in which they are used.

 

Code Examples

#1 Find list of keywords and identifiers in a C# programming

Code - C# Programming

using System;
namespace HelloWorld
{
    class Hello
{         
        static void Main(string[] args)
        {
          Console.WriteLine("Hello World!");
        }
    }
}
Copy The Code & Try With Live Editor
Advertisements

Demonstration


C# Programming Keywords and Identifiers