你能把这行c#转换成vb.net吗?

时间:2009-05-25 12:26:54

标签: c# asp.net-mvc vb.net

我尝试了很多东西,但我总是得到“无法将字符串转换为membershipuser”

来自ASP.Net MVC Membership Starter Kit

来自文件ListUsers.aspx的这一行

var users = (ViewData["Users"] as List<MembershipUser>);

ViewData [“Users”]来自

    public virtual ViewResult Index( int? pageIndex, int? pageSize )
    {
        ViewData["Title"] = "Membership Administration";
        int totalRecords;
        var members = Membership.GetAllUsers( pageIndex ?? 0, pageSize ?? 25, out totalRecords );
        ViewData["Users"] = ToList<MembershipUser>( members );
        ViewData["Roles"] = dotNetRoles.GetAllRoles().ToList();
        return View( "ListUsers" );
    }

谢谢!

1 个答案:

答案 0 :(得分:7)

Dim users = TryCast(ViewData("Users"), List(Of MembershipUser))