there are names inside the Titles array and i want to know what names are in there and i want to place the numbers on a separate array. Example i want to get all the names with this format: “Name 1″,”Name 2″,”Name 3” but what happens is that it gets also the names with format: “Name 1″,”Name1″,”SampleName1” and “FirstNameLast” because i am using a substring. I provided the code i have below.
List<int> ArrayCounter = new List<int>();
foreach(Title titlename in Titles)
{
int length = "StringFromResource".length;
if(titlename.name.length == length)
{
if (!UntitledPolicyArrayCounter.Contains(0))
UntitledPolicyArrayCounter.Add(0);
}
else
{
if (!ArrayCounter.Contains(Convert.ToInt32(titlename.name.Substring(length + 1))))
ArrayCounter.Add(Convert.ToInt32(titlename.name.Substring(length + 1)));
}
}
i want to be able to get only the names with the format: “Name 1”. How do i accomplish this without using regex?
You could use the StartsWith function. I’m still quite vague on what your code is trying to do. I feel example input and expected output might better clarify what you want. Here is some code that might help if I understand what you are trying to do. I might be a little off with my substring functions(you might need an additional +1).
http://msdn.microsoft.com/en-us/library/baketfxw.aspx