Why doesn't this string.Format() return string, but dynamic?

后端 未结 3 1300
野性不改
野性不改 2020-12-31 10:12
@{
    ViewBag.Username = \"Charlie Brown\";
    string title1 = string.Format(\"Welcome {0}\", ViewBag.Username);
    var title2 = string.Format(\"Welcome {0}\", Vi         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 10:14

    It's the view bag which is dynamic.

    If you use actual username (instead of ViewBag.UserName)it would work. Or cast (string)ViewBag.Username into string.

提交回复
热议问题