I have a function that accepts a string array as a parameter
public static void LogMethodStart(string[] parameters)
{
AddLogEntry("Starting Method", parameters); //this does not work
}
public static void AddLogEntry(string[] parameters)
{
using(StreamWriter sw = new StreamWriter(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), FileName), true))
{
foreach (string p in parameters)
{
stream.WriteLine(p.ToString() + DateTime.Now.ToString());
}
}
}
Is there a way to pass an element to be included as an Array without having to do some Array.resize() operation and check for null etc...?
Change your method signature to this:
Then you can call it in a couple of ways:
Both of these will look the same inside the method.
EDIT:
Modify your LogMethodStart body: