VB to C# Conversion Advice...

C

clintonG

From page 3 of "Personalization in ASP.NET" [1] I don't fully understand how
to convert the signature of the following code snippet or the
ASP.HttpProfile assignment which follows...

Sub Profile_MigrateAnonymous(ByVal sender As Object, ByVal e As
ProfileMigrateEventArgs)
Dim anonymousProfile As ASP.HttpProfile =
Profile.GetProfile(e.AnonymousId)
If anonymousProfile.Cart IsNot Nothing Then
Profile.Cart = anonymousProfile.Cart
End If
End Sub

The code is supposed to be used in the global.asax. I do not yet understand
what appears to me to be the user defined ProfileMigrateEventArgs type. Any
referrals to documentation to help me learn more about this construct or
your comments are needed. When rewriting the signature which if any access
modifier should be used? Which type defines such a construct?

My attempt to rewrite the VB ASP.HttpProfile assignment as follows also
fails...

ASP.HttpProfile anonymousProfile = new ASP.HttpProfile( );
anonymousProfile = Profile.GetProfile(e.AnonymousId);

I'd be happy with a reference to documents explaining these constructs but
by all means, if anybody wants to write code for me who am I to complain?
:)

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET (e-mail address removed)
URL http://www.metromilwaukee.com/clintongallagher/

[1]
http://www.ondotnet.com/pub/a/dotnet/2004/08/16/whidbey_personalization.html
 
M

Mattias Sjögren

The code is supposed to be used in the global.asax. I do not yet understand
what appears to me to be the user defined ProfileMigrateEventArgs type. Any
referrals to documentation to help me learn more about this construct or
your comments are needed.
http://msdn2.microsoft.com/library/60dxe0b1.aspx


When rewriting the signature which if any access
modifier should be used?

The default (privatee) should work fine.

My attempt to rewrite the VB ASP.HttpProfile assignment as follows also
fails...

ASP.HttpProfile anonymousProfile = new ASP.HttpProfile( );
anonymousProfile = Profile.GetProfile(e.AnonymousId);

Get rid of the instantioation, and combine it to

ASP.HttpProfile anonymousProfile = Profile.GetProfile(e.AnonymousId);



Mattias
 
D

David Anton

The equivalent C# code, produced by our Instant C# VB.NET to C#
converter is:

public void Profile_MigrateAnonymous(object sender,
ProfileMigrateEventArgs e)
{
ASP.HttpProfile anonymousProfile =
Profile.GetProfile(e.AnonymousId);
if (anonymousProfile.Cart != null)
{
Profile.Cart = anonymousProfile.Cart;
}
}

Download our supported Demo Edition at
http://www.instantcsharp.com

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
C

clintonG

Thanks David, I came up with the same (eventually) and while some converters
choked on the whole thingthe real problem has been the ;} expected exception
when the code as shwon is used in the global.asax Application_Start code
block.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top