L1 Csharp
L1 Csharp
Character
String
Boolean
Integers
Floating point
Variables
Variables are use to store up temporary data to be
use in our in our runtime
Identifiers
An identifier is a name given to a programming element, such as
a variable, function, class, module, or any other user-defined
item. Identifiers are used for identification purposes, making it
possible for programmers to refer to these elements in their code.
Naming:
Purpose:
The primary purpose of identifiers is to provide a human-readable way
to reference the various elements of a program. This makes the code
more understandable and maintainable
Rules of Identifiers
Subsequent Characters:
After the first character, identifiers can consist of letters, digits (0-9), and underscores. The use of other
characters, like hyphens or spaces, is typically not allowed.
Case Sensitivity:
Many programming languages, including C, C++, Java, and C#, treat identifiers as case-sensitive. This
means that Variable, variable, and VARIABLE would be considered distinct identifiers.
No Reserved Words:
Identifiers cannot be the same as reserved words or keywords of the programming language. Reserved
words have special meaning in the language syntax, such as if, else, while, class, return, etc .
using System; Syntax Example:
In the provided code, double salary = 80000.50; declares a
variable named salary of type double and initializes it with the
class Program value 80000.50. This means that salary can store decimal
{ numbers, and in this case, it's being used to represent a
monetary value.
static void Main()
{
Syntax Example:
int age = 30; In the provided code, bool isEmployed = true; declares a
string name = "John Doe"; variable named isEmployed of type bool and initializes it with
bool isEmployed = true; the value true. This implies that the variable isEmployed is
being used to represent the employment status of an individual,
double salary = 80000.50;
with true indicating that the individual is employed.
class Program The + operator inside the Console.WriteLine statement in C# is used for
string concatenation. String concatenation is the process of combining (or
{ appending) one string to the end of another string.
static void Main()
{
int number1 = 5; // First number to add
int number2 = 3; // Second number to add
Console.WriteLine("The sum of " + number1 + " and " + number2 + " is: " + sum);
}
}