c# - Accepting a non fixed length group of parameters in a function -


so i'm trying build logging function, i'm hoping taking format

public static void addtolog(guid someid, logarea mylogger, string message, object object1, object object2... ... ...); 

the second last parameter i'd accept string in format of akin string.format , last x parameters objects replace string format with.

i'm having hard time because can't remember programming concept called search find examples of in c#. realise there's fantastic logging packages out there - need special that's why i'm re-inventing wheel :d

could suggest how tell c# not expect fixed length of parameters? (and bonus points if knows how best document in /// notation i'd appreciate it).

you looking params[].

public static void addtolog(guid someid, logarea mylogger, string message, params object[] list) {     // can use array     console.writeline("guid:{0} message:{1} objects:{2}"         , someid, message, string.join(",", list)); } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -