Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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.
Comment

PREVIOUS NEXT
Code Example
Csharp :: get client ip address c# 
Csharp :: unity c# foreach 
Csharp :: unity set mouse 
Csharp :: get description from enum c# 
Csharp :: how to install jdk on linux manjaro 
Csharp :: redirect to another controller page in asp.net core 
Csharp :: c# enum to int 
Csharp :: add mime type for woff in web.config 
Csharp :: c# dictionary to json 
Csharp :: how to get integer value from textbox in c# 
Csharp :: ienumerable foreach 
Csharp :: add text to combobox c# 
Csharp :: unity vs unreal for beginners 
Csharp :: unity actions 
Csharp :: c# add string to array 
Csharp :: unity call function on animation end 
Csharp :: how to add item in list at first position c# 
Csharp :: update squence c# 
Csharp :: c# cancellationtoken example 
Csharp :: Convert array of strings to List<string 
Csharp :: C# add two numbers using a method 
Csharp :: recursive reverse linked list 
Csharp :: get x and y of mouse uinty 
Csharp :: Entity Framework Core 3.1 Return value (int) from stored procedure 
Csharp :: c# settings file 
Csharp :: c# get certain character from string 
Csharp :: get tag unity 
Csharp :: exceldatareader example c# 
Csharp :: check an enum containa an int or not in C# 
Csharp :: methods c# 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =