简体   繁体   中英

What is the meaning of General - {0}, and can we put other numbers instead of 0, and does this “Format” means formatting of the image

I'm Using ASP.NET. In the ItemTemplate of the DataList I dragged an image. In the imageURL, field binding, the Format = none or General - {0}. I want to know what is the meaning of General - {0}, and can we put other numbers instead of 0. Another issue is does this "Format" means formatting of the image or what?

That is nothing more than a format string, such as the kind used by the String.Format method. In this case, it is used to allow the URL to be constructed from a combination of constants and data.

It's basically set around zero based string arrays.

var first = "first";    // {0}
var second = "second";  // {1}
var third = "third";    // {2}
string.Format("{0}, {1}, {2}.", first, second, third)
// first, second, third.

or

var strings = new [] {
    "first",   // {0}
    "second",  // {1}
    "third"};  // {2}
string.Format("{0}, {1}, {2}.", strings);
// first, second, third.

are the same thing

also, this MSDN link might lend a little more info.

Essentially if you have to create a URL on the fly, you'll use a formatted string.

var urlFormat = "http://example.com/images/{0}.jpg";
var image = "image1";
var imageUrl = string.Format(urlFormat, image);
// http://example.com/images/image1.jpg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM