472,977 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 software developers and data experts.

String.Format

san
Hello, all! I have question about String.Format method.

There are two variants: public static string Format(string, params
object[]); and public static string Format(IFormatProvider, string, params
object[]);

What happens if i will use String.Format("{0} and {1}", "one", "two")
instead of String.Format(System.Globalization.CultureInfo.Cur rentCulture,
"{0} and {1}", "one", "two")?

What differense between these two methods?

Then i use FxCop i have a lot of errors with this resolution: "The call to
'String.Format(String format, Object arg0)' does not explicitly provide
IFormatProvider. This should be replaced with a call to an overload that
does: String.Format(IFormatProvider provider, String format, Object[] args)"

Is this really Critical?

Thanks alot, Alex.
Aug 11 '05 #1
2 3980
san wrote:
There are two variants: public static string Format(string, params
object[]); and public static string Format(IFormatProvider, string, params
object[]);

What happens if i will use String.Format("{0} and {1}", "one", "two")
instead of String.Format(System.Globalization.CultureInfo.Cur rentCulture,
"{0} and {1}", "one", "two")?

What differense between these two methods?
None :-)
Then i use FxCop i have a lot of errors with this resolution: "The call to
'String.Format(String format, Object arg0)' does not explicitly provide
IFormatProvider. This should be replaced with a call to an overload that
does: String.Format(IFormatProvider provider, String format, Object[] args)"

Is this really Critical?


It may not be critical, but it's nevertheless an important thing to
understand. I have searched Google and found an article for you that
explains things quite nicely:

http://www.boyet.com/Articles/Specif...tProvider.html

Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Aug 11 '05 #2
Hi,

The IFormatProvider should be used when your application uses globalization
and different cultures.

In FXCop, you can disable this rule, so that it does not give any error if
you are not providing this parameter.
--
Saravanan K V
"san" wrote:
Hello, all! I have question about String.Format method.

There are two variants: public static string Format(string, params
object[]); and public static string Format(IFormatProvider, string, params
object[]);

What happens if i will use String.Format("{0} and {1}", "one", "two")
instead of String.Format(System.Globalization.CultureInfo.Cur rentCulture,
"{0} and {1}", "one", "two")?

What differense between these two methods?

Then i use FxCop i have a lot of errors with this resolution: "The call to
'String.Format(String format, Object arg0)' does not explicitly provide
IFormatProvider. This should be replaced with a call to an overload that
does: String.Format(IFormatProvider provider, String format, Object[] args)"

Is this really Critical?

Thanks alot, Alex.

Aug 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob | last post by:
I'm having trouble the string.Format() throwing exceptions and I can't figure out what I am doing wrong. Given the following setup code: string str = { "one", "two", "three", "four" }; double...
7
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
3
by: Dominique Vandensteen | last post by:
after the very small & vs string.format discussion I did some speed tests... loop of 1.000.000 concatenations of 5 public string variables in a class gave following results: result = a & b...
4
by: David Morris | last post by:
Hi Could somebody please explain what the following line of code means String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1 It's actually the first argument that I don't understand. What is...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
7
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
5
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
3
by: shawrie | last post by:
Hello everyone can anyone please help me? I basically want to set the length of a string variable to help spacing my simple report out. i tried dim test as string(14) but it didnt like that
5
by: jpenguin | last post by:
I'm doing a simple program to learn java. I have the input and math parts right. It just isn't displaying right. It outputs a list of about 11 things-- with the format "string $ xx.xx" In each...
0
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=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 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...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.