Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generics Problem
Message
From
09/07/2010 17:33:32
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Client-side development
Miscellaneous
Thread ID:
01472084
Message ID:
01472090
Views:
49
>I'm trying to write a simple mapping method:
>
>
>
>private D _ConvertUser<S, D>(S Source, D Destionation)
>{
>    D RetVal = default(D);
>
>    if (Source is aspnetUser)
>    {
>        Source = (aspnetUser)Source;
>
>        RetVal = new MyMembershipUser(Source.ProviderName, Source.UserName, Source.ProviderUserKey, Source.Email,
>                                        Source.PasswordQuestion, Source.Comment, Source.IsApproved, Source.IsLockedOut,
>                                        Source.CreationDate, Source.LastLoginDate, Source.LastActivityDate,
>                                        Source.LastPasswordChangedDate, Source.LastLockoutDate, User.IsDomainUser, true);
>
>    }
>    else
>    { 
>    }
>
>    return RetVal;
>}
>
>
>
>It won't compile because the "Source = (aspnetUser)Source;". I get "Cannot convert type 'S' to 'aspnetUser'".
>
>How do I do this?
aspnetUser u = Source as aspnetUser;

if (u != null)
{
    RetVal = new MyMembershipUser(u.ProviderName, u.UserName, ...
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform