I have a dynamically formed string like - part1.abc.part2.abc.part3.abc
In this string I want to know position of second to last \".\" so that i can split string as
Here is another solution:
string aString = "part1.abc.part2.abc.part3.abc";
// Getting string until last dot
var untilLastDot = aString.Substring(0, aString.LastIndexOf("."));
// Now we have string until last dot and last dot here will be last but one
// and getting text from last but one dot to end
string lastWordButOne = aString.Substring(untilLastDot.LastIndexOf(".") + 1);
// Result: part3.abc
hope helps, Thanks!