@{
ViewBag.Username = "Charlie Brown";
string title1 = string.Format("Welcome {0}", ViewBag.Username);
var title2 = string.Format("Welcome {0}", ViewBag.Username);
}
MVC ध्यान में रखते हुए मैं इस तरह मूल्यों का उपयोग करें:यह स्ट्रिंग क्यों नहीं है। फर्मेट() वापसी स्ट्रिंग, लेकिन गतिशील?
@Html.ActionLink(title1, "Index")
@Html.ActionLink(title2, "Index")
यहाँ, title1
ठीक काम करता है। लेकिन title2
ActionLink एक संकलक त्रुटि के साथ विफल:
CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'StandardHeader' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
string.Format()
काफी कुछ भार के है, लेकिन वापसी प्रकार हमेशा स्ट्रिंग है। var
का उपयोग कर परिवर्तनीय घोषणा क्यों विफल हो जाती है?
मुझे संदेह है कि आपके द्वारा दिए गए कोड से आपको वह त्रुटि संदेश मिला है। मुझे संदेह है कि यह कोड का एक अलग बिट है। –