Home All Groups Group Topic Archive Search About

help converting c# to c++?

Author
16 Aug 2006 10:53 AM
Joel
Is there any way to convert this code to c++ from c#?

System.Web.HttpContext.Current.Session["CookieContainer"] =
outputChannel.Options.CookieContainer;

Thanks in advance.
Regards Joel

Author
16 Aug 2006 11:41 AM
Kevin Spencer
In C#, that would be:

System.Web.HttpContext.Current.Session["CookieContainer"] =
    outputChannel.Options.CookieContainer;

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?


Show quote
"Joel" <J***@discussions.microsoft.com> wrote in message
news:C46F6531-9831-4A4A-B749-5A0A0CD163C6@microsoft.com...
> Is there any way to convert this code to c++ from c#?
>
> System.Web.HttpContext.Current.Session["CookieContainer"] =
> outputChannel.Options.CookieContainer;
>
> Thanks in advance.
> Regards Joel
Author
16 Aug 2006 11:54 AM
Joel
well thanks but i meant a conversion the other way... :)
c# to c++

Regards Joel.

Show quote
"Kevin Spencer" wrote:

> In C#, that would be:
>
> System.Web.HttpContext.Current.Session["CookieContainer"] =
>     outputChannel.Options.CookieContainer;
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Chicken Salad Surgery
>
> Orange you bland I stopped splaying bananas?
>
>
> "Joel" <J***@discussions.microsoft.com> wrote in message
> news:C46F6531-9831-4A4A-B749-5A0A0CD163C6@microsoft.com...
> > Is there any way to convert this code to c++ from c#?
> >
> > System.Web.HttpContext.Current.Session["CookieContainer"] =
> > outputChannel.Options.CookieContainer;
> >
> > Thanks in advance.
> > Regards Joel
>
>
>
Author
16 Aug 2006 2:27 PM
Kevin Spencer
I must be dyslexic this morning!

I do seem to remember laying awake all night wondering if there really is a
dog...

--

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?


Show quote
"Joel" <J***@discussions.microsoft.com> wrote in message
news:DBDF508F-0C05-4DC8-A052-2301282AA630@microsoft.com...
> well thanks but i meant a conversion the other way... :)
> c# to c++
>
> Regards Joel.
>
> "Kevin Spencer" wrote:
>
>> In C#, that would be:
>>
>> System.Web.HttpContext.Current.Session["CookieContainer"] =
>>     outputChannel.Options.CookieContainer;
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Chicken Salad Surgery
>>
>> Orange you bland I stopped splaying bananas?
>>
>>
>> "Joel" <J***@discussions.microsoft.com> wrote in message
>> news:C46F6531-9831-4A4A-B749-5A0A0CD163C6@microsoft.com...
>> > Is there any way to convert this code to c++ from c#?
>> >
>> > System.Web.HttpContext.Current.Session["CookieContainer"] =
>> > outputChannel.Options.CookieContainer;
>> >
>> > Thanks in advance.
>> > Regards Joel
>>
>>
>>
Author
16 Aug 2006 2:09 PM
Carl Daniel [VC++ MVP]
Joel wrote:
> Is there any way to convert this code to c++ from c#?
>
> System.Web.HttpContext.Current.Session["CookieContainer"] =
> outputChannel.Options.CookieContainer;

Assuming you're talking about C++/CLI (VC++ 2005 only), then it'd be
something like:

System::Web::HttpContext::Current->Session["CookieContainer"] =
outputChannel->Options->CookieContainer;

If you're talking about ISO standard C++, then it'd be something completely
different, since none of those classes is accessible from standard (native,
unmanaged) C++.

-cd
Author
16 Aug 2006 4:11 PM
Joel
No actually I was talking about vc++ 2003.
Sorry for not making that clear.

Its not working with the ["CookieContainer"]  part.

I have now solved my issue i another way but im still curious if and how its
possible to translate that part?

Regards
Joel

Show quote
"Carl Daniel [VC++ MVP]" wrote:

> Joel wrote:
> > Is there any way to convert this code to c++ from c#?
> >
> > System.Web.HttpContext.Current.Session["CookieContainer"] =
> > outputChannel.Options.CookieContainer;
>
> Assuming you're talking about C++/CLI (VC++ 2005 only), then it'd be
> something like:
>
> System::Web::HttpContext::Current->Session["CookieContainer"] =
> outputChannel->Options->CookieContainer;
>
> If you're talking about ISO standard C++, then it'd be something completely
> different, since none of those classes is accessible from standard (native,
> unmanaged) C++.
>
> -cd
>
>
>
Author
16 Aug 2006 5:41 PM
Carl Daniel [VC++ MVP]
"Joel" <J***@discussions.microsoft.com> wrote in message
news:FEDAB0AF-866F-4E63-BCE9-C56A8390081F@microsoft.com...
> No actually I was talking about vc++ 2003.
> Sorry for not making that clear.
>
> Its not working with the ["CookieContainer"]  part.
>
> I have now solved my issue i another way but im still curious if and how
> its
> possible to translate that part?

I think you have to call the indexer by name using function call syntax
instead of the indexer syntax.  The name of the indexer should be get_Item,
so it'd be:

System::Web::HttpContext::Current->Session->get_Item("CookieContainer") =
outputChannel->Options->CookieContainer;

-cd
Author
16 Aug 2006 10:21 PM
Peter Bromley
Carl Daniel [VC++ MVP] wrote:
Show quote
> "Joel" <J***@discussions.microsoft.com> wrote in message
> news:FEDAB0AF-866F-4E63-BCE9-C56A8390081F@microsoft.com...
>
>>No actually I was talking about vc++ 2003.
>>Sorry for not making that clear.
>>
>>Its not working with the ["CookieContainer"]  part.
>>
>>I have now solved my issue i another way but im still curious if and how
>>its
>>possible to translate that part?
>
>
> I think you have to call the indexer by name using function call syntax
> instead of the indexer syntax.  The name of the indexer should be get_Item,
> so it'd be:
>
> System::Web::HttpContext::Current->Session->get_Item("CookieContainer") =
> outputChannel->Options->CookieContainer;
>

HttpContext.Current.Session["CookieContainer"]

is actually C# shorthand for

HttpContext.Current.Session.Item["CookieContainer"]

So... in C++

HttpContext::Current->Session->Item["CookieContainer"]


C# treats Item[xxx] as a special case and allows you to drop the
property name "Item".

Cheers,

Peter
Author
17 Aug 2006 12:32 AM
Carl Daniel [VC++ MVP]
Show quote
"Peter Bromley" <no***@nowhere.com> wrote in message
news:eLSqNJYwGHA.3364@TK2MSFTNGP02.phx.gbl...
> Carl Daniel [VC++ MVP] wrote:
>> "Joel" <J***@discussions.microsoft.com> wrote in message
>> news:FEDAB0AF-866F-4E63-BCE9-C56A8390081F@microsoft.com...
>>
>>>No actually I was talking about vc++ 2003.
>>>Sorry for not making that clear.
>>>
>>>Its not working with the ["CookieContainer"]  part.
>>>
>>>I have now solved my issue i another way but im still curious if and how
>>>its
>>>possible to translate that part?
>>
>>
>> I think you have to call the indexer by name using function call syntax
>> instead of the indexer syntax.  The name of the indexer should be
>> get_Item, so it'd be:
>>
>> System::Web::HttpContext::Current->Session->get_Item("CookieContainer") =
>> outputChannel->Options->CookieContainer;
>>
>
> So... in C++
>
> HttpContext::Current->Session->Item["CookieContainer"]

....which is just shorthand for

HttpContext::Current->Session->get_Item("CookieContainer")

Both work in Managed C++ (old syntax), while

HttpContext::Current->Session->default["CookieContainer"]

and

HttpContext::Current->Session["CookieContainer"]

both work in C++/CLI (new syntax).

-cd
Author
16 Aug 2006 10:35 PM
David Anton
The following two will work in C++/CLI:

HttpContext::Current->Session["CookieContainer"]

HttpContext::Current->Session->default["CookieContainer"]

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#


Show quote
"Carl Daniel [VC++ MVP]" wrote:

> "Joel" <J***@discussions.microsoft.com> wrote in message
> news:FEDAB0AF-866F-4E63-BCE9-C56A8390081F@microsoft.com...
> > No actually I was talking about vc++ 2003.
> > Sorry for not making that clear.
> >
> > Its not working with the ["CookieContainer"]  part.
> >
> > I have now solved my issue i another way but im still curious if and how
> > its
> > possible to translate that part?
>
> I think you have to call the indexer by name using function call syntax
> instead of the indexer syntax.  The name of the indexer should be get_Item,
> so it'd be:
>
> System::Web::HttpContext::Current->Session->get_Item("CookieContainer") =
> outputChannel->Options->CookieContainer;
>
> -cd
>
>
>
Author
17 Aug 2006 12:24 AM
Carl Daniel [VC++ MVP]
"David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
news:D2F29736-8755-4B94-9A87-AC85CBB65FB2@microsoft.com...
> The following two will work in C++/CLI:

Yes, we've already covered that.  The question was about MC++ 2003.

-cd
Author
17 Aug 2006 7:49 AM
Joel
Thank you all for that important piece of knowledge.

It will help me in my future development.

Regards
Joel

Show quote
"Carl Daniel [VC++ MVP]" wrote:

> "David Anton" <DavidAn***@discussions.microsoft.com> wrote in message
> news:D2F29736-8755-4B94-9A87-AC85CBB65FB2@microsoft.com...
> > The following two will work in C++/CLI:
>
> Yes, we've already covered that.  The question was about MC++ 2003.
>
> -cd
>
>
>

AddThis Social Bookmark Button