C# - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

C# Expression

C# Expression

shape Description

The most basic expression consists of an operator,two operands and an assignment.

shape Example

The following is an example of an expression: [csharp] int result = 3 + 2; where + is Operator and 3,2 are Operands [/csharp]

shape More Info

Expressions in C# can use operators that in turn use other expressions such as parameters or method calls. The parameters that are used in turn uses other method calls. So,expressions can range from elementary to very complex.
  • Regular Expression
  • Lambda Expression

shape Example

Following are two examples of expressions: 1.((x 4)) || ((x > 25) && (x < 30)) 2.System.Convert.ToInt32("10")

Regular Expression

shape Description

A regular expression, is a special text string for describing a search pattern. Fundamentally, a regular expression is a pattern describing a certain amount of text. Their name comes from the mathematical theory on which they are founded. The regular expression is abbreviated to regex or regexp. Regex is the most commonly preferred abbreviation, because it is easy to pronounce the plural “regexes”. They clearly distinguish the pattern from the surrounding text and punctuation.

shape Example

The example provided below shows a simple program. [csharp] using System; using System.Text.RegularExpressions; namespace SpLessons { class Program { public static void Main(string[] args) { Regex regex = new Regex(@"\d+"); Match reg = regex.Match("SPLessons-3 Chapter Regular Expression"); if (reg.Success) { Console.WriteLine(reg.Value); } } } } [/csharp] Output: