Exposing a "null" dotnet object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Hemmingsen

    #1

    Exposing a "null" dotnet object

    Hi,

    I have a dotnet object (implemented in mc++ and used in c#) which have a
    property called "Info". The Info property is also a dotnet object
    (implemented in mc++). In the constructor of the "main" object I want to
    initialize the property "Info" to null in a way that will make the c#
    programmer (the user) able to write:

    if (MyObj.Info==nu ll) {..}

    I've tried to initialize the Info property (in mc++) as follows:

    this->Info=0; // Note Info is a __gc class pointer

    but the above c# code always returns false.

    Any suggestions?

    Peter





  • Nishant S

    #2
    Re: Exposing a "null&quot ; dotnet object

    Strange. I could not reproduce this problem.

    MC++ class library :-

    namespace mcpp_del
    {
    public __gc class Class1
    {
    public:
    Object* GetObj()
    {
    Object* o = 0;
    return o;
    }
    };
    }

    C# program :-

    using System;
    using mcpp_del;

    namespace ConsoleApplicat ion4
    {
    class Class2
    {
    [STAThread]
    static void Main(string[] args)
    {
    Class1 c1 = new Class1();
    Console.WriteLi ne(c1.GetObj() == null);
    }
    }
    }

    The output is :-

    True

    --
    Regards,
    Nish [VC++ MVP]



    "Peter Hemmingsen" <phe@softco.d k> wrote in message
    news:Ozrz4KHeDH A.1888@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi,
    >
    > I have a dotnet object (implemented in mc++ and used in c#) which have a
    > property called "Info". The Info property is also a dotnet object
    > (implemented in mc++). In the constructor of the "main" object I want to
    > initialize the property "Info" to null in a way that will make the c#
    > programmer (the user) able to write:
    >
    > if (MyObj.Info==nu ll) {..}
    >
    > I've tried to initialize the Info property (in mc++) as follows:
    >
    > this->Info=0; // Note Info is a __gc class pointer
    >
    > but the above c# code always returns false.
    >
    > Any suggestions?
    >
    > Peter
    >
    >
    >
    >
    >[/color]


    Comment

    • Yan-Hong Huang[MSFT]

      #3
      RE: Exposing a &quot;null&quot ; dotnet object

      Hello Peter,

      Thanks for posting in the group. I have tested it on my side and got the
      same result as Nish.

      I have replied this question in dotnet.language s.vc group. Could you please
      check it when you have free time? I will follow up you there.

      Best regards,
      Yanhong Huang
      Microsoft Online Partner Support

      Get Secure! - www.microsoft.com/security
      This posting is provided "AS IS" with no warranties, and confers no rights.

      --------------------
      !From: "Peter Hemmingsen" <phe@softco.d k>
      !Subject: Exposing a "null" dotnet object
      !Date: Thu, 11 Sep 2003 16:44:06 +0200
      !Lines: 24
      !X-Priority: 3
      !X-MSMail-Priority: Normal
      !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
      !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
      !Message-ID: <Ozrz4KHeDHA.18 88@TK2MSFTNGP12 .phx.gbl>
      !Newsgroups:
      microsoft.publi c.dotnet.langua ges.csharp,micr osoft.public.do tnet.languages. v
      c
      !NNTP-Posting-Host: heimdal.softco. dk 80.199.79.33
      !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
      !Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vc:28224
      microsoft.publi c.dotnet.langua ges.csharp:1841 08
      !X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
      !
      !Hi,
      !
      !I have a dotnet object (implemented in mc++ and used in c#) which have a
      !property called "Info". The Info property is also a dotnet object
      !(implemented in mc++). In the constructor of the "main" object I want to
      !initialize the property "Info" to null in a way that will make the c#
      !programmer (the user) able to write:
      !
      !if (MyObj.Info==nu ll) {..}
      !
      !I've tried to initialize the Info property (in mc++) as follows:
      !
      !this->Info=0; // Note Info is a __gc class pointer
      !
      !but the above c# code always returns false.
      !
      !Any suggestions?
      !
      !Peter
      !
      !
      !
      !
      !
      !

      Comment

      Working...