I have a simple debug and logging class and I would like to be able to send
a non-formatted string to my various printing methods, much like
string.format().
I have tried to implement this like so:
public void PrintDebugError(string format, object[] parameters)
{
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this:
int someValue = 666;
m_debug.PrintDebugError("Loaded {0} shots from the database...", someValue);
I get the obvious error:
The best overloaded method match for 'CAppDebug.PrintDebugError(string,
object[])' has some invalid arguments
So looking at the string.format(), how do they do it? If I create an object
array, then store the int into the array and pass that, it works fine.
I guess what I'm looking for is a way to specify n parameters..
Any ideas?
-SK 5 11105
Hi sklett,
Use the params keyword. http://msdn.microsoft.com/library/en...clrfparams.asp
For example:
public void Format(params string[] args)
HTH,
Rakesh Rajan
"sklett" wrote: I have a simple debug and logging class and I would like to be able to send a non-formatted string to my various printing methods, much like string.format().
I have tried to implement this like so: public void PrintDebugError(string format, object[] parameters)
{
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this: int someValue = 666;
m_debug.PrintDebugError("Loaded {0} shots from the database...", someValue); I get the obvious error: The best overloaded method match for 'CAppDebug.PrintDebugError(string, object[])' has some invalid arguments
So looking at the string.format(), how do they do it? If I create an object array, then store the int into the array and pass that, it works fine. I guess what I'm looking for is a way to specify n parameters..
Any ideas? -SK
perfect, thanks!!
"Rakesh Rajan" <Ra*********@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com... Hi sklett,
Use the params keyword. http://msdn.microsoft.com/library/en...clrfparams.asp
For example: public void Format(params string[] args)
HTH, Rakesh Rajan
"sklett" wrote:
I have a simple debug and logging class and I would like to be able to
send a non-formatted string to my various printing methods, much like string.format().
I have tried to implement this like so: public void PrintDebugError(string format, object[] parameters)
{
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this: int someValue = 666;
m_debug.PrintDebugError("Loaded {0} shots from the database...",
someValue);
I get the obvious error: The best overloaded method match for 'CAppDebug.PrintDebugError(string, object[])' has some invalid arguments
So looking at the string.format(), how do they do it? If I create an
object array, then store the int into the array and pass that, it works fine. I guess what I'm looking for is a way to specify n parameters..
Any ideas? -SK
Hello sklett,
take a look at the params keyword.
public void PrintDebugError(string format, params object[] parameters)...
HTH
Wes Haggard http://weblogs.asp.net/whaggard/ I have a simple debug and logging class and I would like to be able to send a non-formatted string to my various printing methods, much like string.format().
I have tried to implement this like so: public void PrintDebugError(string format, object[] parameters) {
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this: int someValue = 666; m_debug.PrintDebugError("Loaded {0} shots from the database...", someValue);
I get the obvious error: The best overloaded method match for 'CAppDebug.PrintDebugError(string, object[])' has some invalid arguments So looking at the string.format(), how do they do it? If I create an object array, then store the int into the array and pass that, it works fine. I guess what I'm looking for is a way to specify n parameters.. Any ideas? -SK
Anytime sklett :)
- Rakesh Rajan
"sklett" wrote: perfect, thanks!!
"Rakesh Rajan" <Ra*********@discussions.microsoft.com> wrote in message news:5E**********************************@microsof t.com... Hi sklett,
Use the params keyword. http://msdn.microsoft.com/library/en...clrfparams.asp
For example: public void Format(params string[] args)
HTH, Rakesh Rajan
"sklett" wrote:
I have a simple debug and logging class and I would like to be able to send a non-formatted string to my various printing methods, much like string.format().
I have tried to implement this like so: public void PrintDebugError(string format, object[] parameters)
{
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this: int someValue = 666;
m_debug.PrintDebugError("Loaded {0} shots from the database...", someValue);
I get the obvious error: The best overloaded method match for 'CAppDebug.PrintDebugError(string, object[])' has some invalid arguments
So looking at the string.format(), how do they do it? If I create an object array, then store the int into the array and pass that, it works fine. I guess what I'm looking for is a way to specify n parameters..
Any ideas? -SK
"sklett" <as***@asdfasdfsd.com> wrote in message
news:OD****************@TK2MSFTNGP10.phx.gbl... I have a simple debug and logging class and I would like to be able to send a non-formatted string to my various printing methods, much like string.format().
I have tried to implement this like so: public void PrintDebugError(string format, object[] parameters)
{
string buff = string.Format(format, parameters);
m_outputBox.Items.Add(buff);
}
Then when calling it like this: int someValue = 666;
m_debug.PrintDebugError("Loaded {0} shots from the database...", someValue); I get the obvious error: The best overloaded method match for 'CAppDebug.PrintDebugError(string, object[])' has some invalid arguments
So looking at the string.format(), how do they do it? If I create an object array, then store the int into the array and pass that, it works fine. I guess what I'm looking for is a way to specify n parameters..
Any ideas?
Look up the "params" keywword. If you define your method as
public void PrintDebugError(string format, params object[] parameters)
then it should work.
Chris Jobson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Zlatko Matić |
last post by:
Hi everybody!
Recently I was struggling with client/server issues in MS Access/PostgreSQL
combination.
Although Access is intuitive and easy to use desktop database solution, many
problems...
|
by: Daimy |
last post by:
I meet the same problem below, please help me!
Thanks!
//written by some one
I have developed a windows forms user control, which I am going to host in
Internet Explorer..
I am familiar...
|
by: Julien C. |
last post by:
Hi all,
I have an "EditeItem.aspx" page which lets me edit properties of an "Item".
In the OnClick() event of my Save button, I do save Item changes to the
database and then I redirect the user...
|
by: Alex Nitulescu |
last post by:
Hi.
I have tried to pass two parameters, like this:
Response.Redirect(String.Format("NewPage.aspx?Username={0}, Pass={1}",
txtUserName.Text, txtPass.Text))
But if I pass Username="Alex" and...
|
by: CsharpGuy |
last post by:
I took over an web app (C#) were the developer put everything in a has table
then called a method to execute a stored procedure, now I'm running into some
issues were if I do an update and a NULL...
|
by: carry |
last post by:
Hi everybody,
I need simple string formatting like string.Format() does, but just with
strings what seems not to work.
Can anyone tell me please why this doesn't work and how can it be done? This...
|
by: Larry Bud |
last post by:
I'm writing a class to create a specifically formatted fixed width
file. It's 800 characters wide, consisting of approx 30 fields.
So I need to pass 30 variables, maybe 10 are required. Should...
|
by: =?Utf-8?B?UElFQkFMRA==?= |
last post by:
Given a method like
void F ( params object args ) { ... }
I had always _assumed_ that args would never be null, but now it's been
brought to my attention that if the caller uses
F ( null )...
|
by: (2b|!2b)==? |
last post by:
I am expecting a string of this format:
"id1:param1,param2;id2:param1,param2,param3;id"
The tokens are seperated by semicolon ";"
However each token is really a struct of the following...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |