Friday, 23 June 2017

C# String Format in LSL

Usually at work I use C#. There is a method in the string class of C# called Format. This little beauty of a method replaces any {0}, {1}, {2}, etc with the 1st, 2nd, 3rd parameters of that method. For example String.Format("My name is {0} and I love {1}", "SighFye", "C#"). This will come out as "My name is SighFye and I love C#". This is a method I use a lot in C# and when scripting for Second Life I find the lack of the method a little disappointing. So I decided to create it. Below is a copy of my method that does the same as the C# String.Format.

In my version instead of having dynamic params I use a list variable. So lets test it out. I have added this to my script.

And my results are...
So there it is the C# String.Format method in LSL. Hopefully this can help take you code to a new level.



No comments:

Post a Comment