D
djc
out of all the overloads that pop up via intellisense for
console.writeline() the following one confuses me:
Console.WriteLine (string format, params object[] arg)
1) whats the deal with 'params' there? I am used to this pattern: type var,
type var, type var etc... like: string str, int i, double x. This
console.writeline overload says 'params object[] arg' ?
2) I noticed that the console.writeline( string, object, object, object,
object) overload (from the help file - not intellisense) is not CLS
compliant. It says to use console.writeline(string, object[]). I am going to
write a class to assist me in some common console output tasks and would
like to make it as generic and flexible as possible so for example, I will
not know ahead of time the number of objects I may pass to a
console.writeline call. I have mostly seen the console.writeline used like
so:
console.writeline("some text: {0}, {1}, {2}", var1, var2, var3)
I see it with varying numbers of parameters... however if I am understanding
this correctly then if I wind up passing 4 parameters like so:
console.writeline("some text: {0}, {1}, {2}, {3}", var1, var2, var3, var4)
then it matches the console.writeline( string, object, object, object,
object) overload and will NOT be CLS compliant?
2b) and does this also mean that there is a limit of 4 parameters using this
pattern? for instance the following would not work?
console.writeline("some text: {0}, {1}, {2}, {3}, {4}", var1, var2, var3,
var4, var5)
3) if my assumptions above are correct and my intent is to be able to
utilize a console.writeline method inside a class which will need to work on
varying numbers of parameters is it true then that I should use
console.writeline( string, object[])?
hopefully my questions are clear enough... their probably not.
any input would be appreciated. Thanks.
console.writeline() the following one confuses me:
Console.WriteLine (string format, params object[] arg)
1) whats the deal with 'params' there? I am used to this pattern: type var,
type var, type var etc... like: string str, int i, double x. This
console.writeline overload says 'params object[] arg' ?
2) I noticed that the console.writeline( string, object, object, object,
object) overload (from the help file - not intellisense) is not CLS
compliant. It says to use console.writeline(string, object[]). I am going to
write a class to assist me in some common console output tasks and would
like to make it as generic and flexible as possible so for example, I will
not know ahead of time the number of objects I may pass to a
console.writeline call. I have mostly seen the console.writeline used like
so:
console.writeline("some text: {0}, {1}, {2}", var1, var2, var3)
I see it with varying numbers of parameters... however if I am understanding
this correctly then if I wind up passing 4 parameters like so:
console.writeline("some text: {0}, {1}, {2}, {3}", var1, var2, var3, var4)
then it matches the console.writeline( string, object, object, object,
object) overload and will NOT be CLS compliant?
2b) and does this also mean that there is a limit of 4 parameters using this
pattern? for instance the following would not work?
console.writeline("some text: {0}, {1}, {2}, {3}, {4}", var1, var2, var3,
var4, var5)
3) if my assumptions above are correct and my intent is to be able to
utilize a console.writeline method inside a class which will need to work on
varying numbers of parameters is it true then that I should use
console.writeline( string, object[])?
hopefully my questions are clear enough... their probably not.
any input would be appreciated. Thanks.