473,412 Members | 4,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

how to use 'null' keyword when calling c# dlls in c++ projects?

hi,

I am using visual studio for my c++ project, and have to call a c#
dll. now I met a problem when a methed in c# dll returns null, I
don't know how to use 'null' in c++.

To make it simple, I write a simple example to make my problem clear.
Below is a class A(implemented in c#), the method will return null in
some conditions.

class A{
bool flag;
System::String s;
public System::String getNext(){
if(flag == true)
return s;
else return null;
}
}

in the c++ project , I just want to use the class,like this
A^ a = gcnew A();
if((a->getNext()) != null) //here is the problem, the 'null'
keyword is not defined in c++,
// if I try to use NULL instead
of null, an conversion error will occur.

so, what should I do here?

Thanks!

Aug 3 '07 #1
3 1694
Vivienne wrote:
hi,

I am using visual studio for my c++ project, and have to call a c#
dll. now I met a problem when a methed in c# dll returns null, I
don't know how to use 'null' in c++.
Try "nullptr" instead.
Aug 3 '07 #2
On Aug 3, 12:41 am, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.comwrote:
Vivienne wrote:
hi,
I am using visual studio for my c++ project, and have to call a c#
dll. now I met a problem when a methed in c# dll returns null, I
don't know how to use 'null' in c++.

Try "nullptr" instead.

Thanks

Aug 3 '07 #3
Hi,

You better post this question in a managed C++ group

"Vivienne" <zh**********@gmail.comwrote in message
news:11**********************@m37g2000prh.googlegr oups.com...
hi,

I am using visual studio for my c++ project, and have to call a c#
dll. now I met a problem when a methed in c# dll returns null, I
don't know how to use 'null' in c++.

To make it simple, I write a simple example to make my problem clear.
Below is a class A(implemented in c#), the method will return null in
some conditions.

class A{
bool flag;
System::String s;
public System::String getNext(){
if(flag == true)
return s;
else return null;
}
}

in the c++ project , I just want to use the class,like this
A^ a = gcnew A();
if((a->getNext()) != null) //here is the problem, the 'null'
keyword is not defined in c++,
// if I try to use NULL instead
of null, an conversion error will occur.

so, what should I do here?

Thanks!

Aug 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Schu | last post by:
I have a project with 2 DLLs, one of which is supposed to call the other, but I can't seem to get it to work. I am doing the following: 1) The 2 DLL projects are set up as VB class projects...
4
by: Derrick | last post by:
Long story short: I've been working on a project which includes both designtime and runtime components, for both the PC and Pocket PC. While testing, I've been having problems with Visual Studio...
2
by: Johann Blake | last post by:
I can hardly believe I'm the first one to report this, but having gone through the newsgroup, it appears that way. I would like to open a solution in the VS.NET IDE that consists of multiple...
8
by: Dot net work | last post by:
I need VB.NET's "shadows" functionality inside a C# project. I tried the "new" keyword, but it didn't seem to work, because my particular function does in fact differ in signature to the function...
6
by: Derrick | last post by:
Hello all; Since I do have working code, this is more for my curiosity only. I'm creating a "Plugin" architecture, following some of the many examples on the 'net. Basically what I have is...
4
by: Dixon | last post by:
wats the Diff Between Setting an object to NULL and calling the Dispose() method for that object?
8
by: rakoo | last post by:
I want to question about this virtual keyword , what is neccessty of it .. when base class ponter or simply object assingned to derived class object ,we never want that base class funtion by base...
6
by: tony | last post by:
Hello! I have several projects where each one build a library.(class library or window control library). Now I get some strange compile error when building the *.exe file and doesn't...
4
by: | last post by:
I have learned about compartmentalizing my code base using Class Libraries. I have my common code such as my ORM framework broken out into their own Class Libraries, which are referenced as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.