-7

I cannot seen to find out the purpose of the ^ in a C# method call.

For example:

SomeObject::somemethod(ObjArg^ arg)
{
    // method body
}

What is the effect of the ^?

gunr2171
  • 16,104
  • 25
  • 61
  • 88
englishPete
  • 809
  • 10
  • 15
  • 2
    This looks like C++/CLI, not c# – crashmstr Jul 02 '14 at 18:45
  • 1
    That is not valid c#. You can't do `SomeObject::`, or have a `^` – gunr2171 Jul 02 '14 at 18:45
  • 5
    `I have been a [...] Java [...] programmer for over 20 years` - Welcome to the modern age. You might find C# language features such as LINQ, generics, delegates, and async/await really useful. – Federico Berasategui Jul 02 '14 at 18:47
  • 1
    I think it could be a valid question if it was asked for c++/cli – mtmk Jul 02 '14 at 18:49
  • 1
    possible duplicate of [What does the caret (‘^’) mean in C++/CLI?](http://stackoverflow.com/questions/202463/what-does-the-caret-mean-in-c-cli) – crashmstr Jul 02 '14 at 18:49
  • @MaxwellTroyMiltonKing except for the multiple questions it duplicates. – crashmstr Jul 02 '14 at 18:50
  • 2
    @gunr2171 no, it is *not* a C# question, since that is *not* c# syntax. – crashmstr Jul 02 '14 at 18:51
  • @crashmstr, c# is stated twice, once in the title and once in the body, and the original tags included c#. If the OP made it as a mistake, you would have to radically edit the question to make it not about c#. – gunr2171 Jul 02 '14 at 18:52
  • @crashmstr good point. Thought that as I posted the comment. Thanks for finding a duplicate – mtmk Jul 02 '14 at 18:52
  • 1
    @gunr2171 The code sample is not C# and can not be C#, David Heffernan (286k) ALSO says it is not C#. So... not C# (and *no* edits to code need to make it about C++/CLI) – crashmstr Jul 02 '14 at 18:53
  • Also related: [What does ^ after a type mean in c++?](http://stackoverflow.com/questions/4599290/what-does-after-a-type-mean-in-c?rq=1), [What does the ^ character mean when used in C++ declarations?](http://stackoverflow.com/questions/13953002/what-does-the-character-mean-when-used-in-c-declarations?rq=1), [In C++/CLR, what does a hat character ^ do?](http://stackoverflow.com/questions/500580/in-c-clr-what-does-a-hat-character-do?rq=1), and [What does the ^ do?](http://stackoverflow.com/questions/17835795/what-does-the-do?rq=1) – crashmstr Jul 02 '14 at 18:59

1 Answers1

8

This is not C#. This is C++/CLI. The ^ is the Handle to Object Operator. It is used here to indicate that arg is a handle to a managed class of type ObjArg.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490