hi i want to get just the Crm and the number in the line tenx
string emailsubject = "Email Test 2 CRM:0276002";
public string GetCrmSubjectNum()
{
string final = //;
return "";
}
hi i want to get just the Crm and the number in the line tenx
string emailsubject = "Email Test 2 CRM:0276002";
public string GetCrmSubjectNum()
{
string final = //;
return "";
}
It is a little bit unclear what you want. If you always have "CRM" in the subject, then you could do it like following:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string emailsubject = "Email Test 2 CRM:0276002";
emailsubject = GetCrmSubjectNum(emailsubject);
Console.WriteLine(emailsubject);
Console.Read();
}
public static string GetCrmSubjectNum(string emailsubject)
{
emailsubject = emailsubject.Remove(0, emailsubject.IndexOf("CRM"));
return emailsubject;
}
}
}
I would go with this, because Substring() is the fastest way:
public string GetCrmSubjectNum(string emailSubject)
{
return emailSubject.Substring(emailSubject.IndexOf("CRM:", StringComparison.Ordinal) + "CRM:".Length);
}