简体   繁体   中英

Is it valid to use `<%= “{0}, {1}”, arg1, arg2 %>` in place of `<%= string.Format(“{0}, {1}”, arg1, arg2) %>` in ASP.NET aspx pages

In my aspx pages I often use the following and it works fine:

<%= "{0}, {1}", arg1, arg2 %>

I use ReSharper for code analysis. I just upgraded for v6.1 to 7 and it is giving me the following two errors:

"Expression expected"

"Method '__ReSharper_Render' has 1 parameter(s) but is invoked with 3 argument(s)"

Is the syntax I use incorrect? I would prefer to continue using it as I find it quite elegant and compact. If it is correct (I think it should be as it works), any idea how to tell ReSharper to either ignore it or treat it as valid?

Saurabh, you are using implementation details of ASP.NET. It's bad practice. Better to specify it explicitly:

<%= string.Format("{0}, {1}", arg1, arg2) %>

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