- Posts: 109
NET Wildcards
- JD Cox
- Topic Author
- Offline
- User
Less
More
12 years 5 months ago #2237
by JD Cox
NET Wildcards - Post(2237) was created by JD Cox
I need some help with a C# script. Below is a copy of a NET script I’m using. There are several customers identified here during data imports. Customer A and Customer C work great. However, a new customer, Customer B, has close to 1500 account numbers our (Case) too many for me to script out. The only unique thing is all of their account numbers start with 100* which brings me to my problem. How do I use a wildcard here? I’ve done a fare amount of searching and what I’ve read indicates that “100*” should work. I have a work around in place that uses the customer’s name to identify ID number.
All of the account numbers are ten characters and this is the only customer that has an account number starting with 100.
//Customer A
case "9873000000":
ret = "39";
break;
//Customer B
case "100*":
ret = "40";
break;
//Customer C
case "4609830000":
ret = "41";
break;
Any help would be greatly appreciated
All of the account numbers are ten characters and this is the only customer that has an account number starting with 100.
//Customer A
case "9873000000":
ret = "39";
break;
//Customer B
case "100*":
ret = "40";
break;
//Customer C
case "4609830000":
ret = "41";
break;
Any help would be greatly appreciated
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
12 years 5 months ago #2238
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Re:NET Wildcards - Post(2238)
Hi JD,
.NET doesn’t support wildcards in a switch statement. For this you need a default section in your switch statement. Here you can add an additional if statement with conditions. See script below.
Hope this help?
.NET doesn’t support wildcards in a switch statement. For this you need a default section in your switch statement. Here you can add an additional if statement with conditions. See script below.
Code:
public object DoWork()
{
int nRet = -1; //not found
string s = (string)InValues[0].GetString();
switch(s)
{
case "9873000000":
nRet = 39;
break;
case "4609830000":
nRet = 41;
break;
default:
{
if (s.StartsWith("100"))
nRet = 40;
else if (s.StartsWith("200"))
nRet = 50;
else if (s.StartsWith("300"))
nRet = 60;
// and so on
break;
}
}
return nRet;
}
Hope this help?
Best wishes
Robert Stark
Please Log in or Create an account to join the conversation.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
12 years 5 months ago #2239
by JD Cox
Replied by JD Cox on topic Re:NET Wildcards - Post(2239)
That did it…As always, Robert, you’re a tremendous help.
Thanks You!
Thanks You!
Please Log in or Create an account to join the conversation.
Time to create page: 0.253 seconds