Posts

What is C# If ... Else ? / C# If ... Else क्या है ?

C#  If ... Else C# Conditions and If Statements C# supports the usual logical conditions from mathematics: Less than:  a < b Less than or equal to:  a <= b Greater than:  a > b Greater than or equal to:  a >= b Equal to  a == b Not Equal to:  a != b You can use these conditions to perform different actions for different decisions. C# has the following conditional statements: Use  if  to specify a block of code to be executed, if a specified condition is true Use  else  to specify a block of code to be executed, if the same condition is false Use  else if  to specify a new condition to test, if the first condition is false Use  switch  to specify many alternative blocks of code to be executed The if Statement Use the  if  statement to specify a block of C# code to be executed if a condition is  True . Syntax if ( condition ) { // block of code to...

What is C# Booleans ? / C# Booleans क्या है ?

C# Booleans Very often, in programming, you will need a data type that can only have one of two values, like: YES / NO ON / OFF TRUE / FALSE For this, C# has a  bool  data type, which can take the values  true  or  false . Boolean Values A boolean type is declared with the  bool  keyword and can only take the values  true  or  false : Example bool isCSharpFun = true ; bool isFishTasty = false ; Console . WriteLine ( isCSharpFun ) ; // Outputs True Console . WriteLine ( isFishTasty ) ; // Outputs False However, it is more common to return boolean values from boolean expressions, for conditional testing (see below). Boolean Expression A  Boolean expression  is a C# expression that returns a Boolean value:  True  or  False . You can use a comparison operator, such as the  greater than  ( > ) operator to find out if an expression (or a variable) is true: E...

What is the C# Strings ? / C# Strings क्या होता है ?

C# Strings Strings are used for storing text. A  string  variable contains a collection of characters surrounded by double quotes: Example Create a variable of type  string  and assign it a value: string greeting = "Hello" ; String Length A string in C# is actually an object, which contain properties and methods that can perform certain operations on strings. For example, the length of a string can be found with the  Length  property: Example string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Console . WriteLine ( "The length of the txt string is: " + txt . Length ) ; Other Methods There are many string methods available, for example  ToUpper()  and  ToLower() , which returns a copy of the string converted to uppercase or lowercase: Example string txt = "Hello World" ; Console . WriteLine ( txt . ToUpper ( ) ) ; // Outputs "HELLO WORLD" Console . WriteLine ( txt . ToLower ( ) ) ; // Output...