Looking for alternative for String.Format

It appears that string.format is not exists on .NETMF, what can I do instead?

Thanks

What is it that you are trying to accomplish?

@ Jeff_Birt - Ok, I found out this:

https://netmfcommonext.codeplex.com

So thanks for replying :slight_smile:

If your just looking to concatenate some strings and string representation of numbers you can do that without String.Format.



String.Format provides a familiar printf type syntax but both methods accomplish the same thing. My guess is that the extension you linked to just does concatenation as shown above.

For more than 2 strings you can use String.Concat() instead of + Operator to boost performance

Looks like I’m a little late in the game but I also missed string.format function so I created extension method.


        public static string Format(this string format, params object[] args)
        {
            if (args == null || args.Length == 0)
                return format;

            StringBuilder sb = new StringBuilder(format);
            for (int i = 0; i < args.Length; i++)
                sb.Replace("{" + i + "}", args[i].ToString());

            return sb.ToString();
        }