If you want to do something like that in a library, then the best way is to return the desired string from the library method like this:
Code: Select all
public string AppendDateTime(string input) {
return input + "-" + System.DataTime.Now.Ticks.ToString();
}
//or you can make it an extension method:
public string AppendDateTime(this string input) {
return input + "-" + System.DataTime.Now.Ticks.ToString();
}
Then in your user-code modules you would do this:
Code: Select all
VendorName = MyLib.AppendDateTime(VendorName);
// as extension method:
VendorName = VendorName.AppendDateTime();
But, one-way or another, you always have to have some concrete implementations for the test to use, either by doing it this way, or the way I showed before.
The thing about putting something this simple in a library is that it usually is only really useful for some specific cases, and even then, doing it the first way I suggested is usually preferred because the library call can hide what the real intention of the code is if it's not named really well. Plus, it frees you from always having to include the library for just the one line of code.
The rule-of-thumb is, if you can do it in a single, simple statement, you should leave it. If you can't, then make it a method.
Usually the simplest way is the best.
Shortcuts usually aren't...