Ala*_*an2 0 c# asp.net-mvc razor asp.net-mvc-3
我在ASP MVC Razor文件中尝试以下代码:
var topic = ViewData["TopicID"];
var mustBeReplaced = string.Empty;
var topicValue = Model.Topic;
var replaceResult = string.Empty;
if (topic.Contains(topicValue)) {
mustBeReplaced = "value=\"" + topicValue + "\"";
replaceResult = mustBeReplaced + " selected=\"selected\"";
topic = topic.Replace(mustBeReplaced, replaceResult);
}
Run Code Online (Sandbox Code Playgroud)
但是我收到一条错误消息:
object'不包含'Contains'的定义和最佳扩展方法重载