How to put email in value for Switch

yomomma

Пользователь
Регистрация
17.02.2013
Сообщения
53
Благодарностей
2
Баллы
8
How do I get the value "[email protected]" to be read in Switch as an email with "gmail.com" in the 0 value?
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 269
Благодарностей
5 853
Баллы
113

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113

yomomma

Пользователь
Регистрация
17.02.2013
Сообщения
53
Благодарностей
2
Баллы
8
Yes, I am having difficulty with getting it to identify specific emails.

Hi. If I understood you right then first you have to do regex and get email service from your email. When you get gmail.com in separate variable then you can set gmail.com in 0 in switch and set this new variable to check against.
If I have 2 different emails (i.e. gmail and outlook) then I have to create variables for both?
 

esouldy

Client
Регистрация
28.02.2016
Сообщения
185
Благодарностей
92
Баллы
28
c# action?
Код:
string email = project.Variables["email"].Value.Substring(project.Variables["email"].Value.IndexOf('@') + 1);
//uncomment for debugging
//return email;
switch (email)
{
    case "gmail.com":
        return "gmail";
        break;
    case "outlook.com":
        return "outlook";
        break;
    default:
           return "bad email";
}
 

yomomma

Пользователь
Регистрация
17.02.2013
Сообщения
53
Благодарностей
2
Баллы
8
Thanks for the idea and code.
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)