Horje
switch case c# contains Code Example
switch case c# contains
Correct final syntax for [Mr. C]s answer.

With the release of VS2017RC and its C#7 support it works this way:

switch(message)
{
    case string a when a.Contains("test2"): return "no";
    case string b when b.Contains("test"): return "yes";
}
You should take care of the case ordering as the first match will be picked. That's why "test2" is placed prior to test.




Csharp

Related
datagridview column color c# Code Example datagridview column color c# Code Example
c# adding to a list Code Example c# adding to a list Code Example
get index c# Code Example get index c# Code Example
c# linq select from object list Code Example c# linq select from object list Code Example
make window not resizable wpf Code Example make window not resizable wpf Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10