I found the following C++ code (comments added myself):
// frame_name is a char array
// prefix is std::string
// k is a for loop counter
// frames is a std::vector string
sprintf(frameName, "%s_%0*s.bmp", prefix.c_str(), k, frames[k].c_str());
I then try to translate it to C#
// prefix is string
// k is a for loop counter
// frames is List<string>
string frameName = string.Format("{0}_(what goes in here?).bmp", prefix, k, frames[k]);
Basically, what would be the C# equivalent of the C++ format string "%s_%0*s.bmp"?
Edit, @Mark Byers:
I've tried your code and made a little test program:
static void Main(string[] args)
{
List<string> frames = new List<string>();
frames.Add("blah");
frames.Add("cool");
frames.Add("fsdt");
string prefix = "prefix";
int n = 2;
int k = 0;
string frameName = string.Format("{0}_{1}.bmp", prefix, frames[k].PadLeft(n, '0'));
Console.WriteLine(frameName); // outputs prefix_blah.bmp, should output prefix_00blah.bmp
Console.ReadLine();
}
It's not padding for some reason.
Edit: Got it working; won't pad if n = 2.