473,405 Members | 2,167 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,405 software developers and data experts.

DefaultValue and String in Managed C++

Hi,
anyone an idea how to get DefaultValue's working for
String properties in managed C++.
I wrote a component in managed C++ which I plan to consume
in C#. Now the IDE keeps inserting null-assignments for
the string properties, while I've specified that NULL is
the default value. Other types work well.

thanks in advance,
Bram.
Nov 15 '05 #1
3 4186
Bram,

microsoft.public.dotnet.languages.vc is a better group for C++
questions.

Now the IDE keeps inserting null-assignments for
the string properties, while I've specified that NULL is
the default value. Other types work well.


Can you post your code?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
Hi,
thanks for looking into my problem.
the code (managed C++) goes like this:

public __gc class SomeClass : public System::ComponentModel::Component
{
public:
SomeClass();
SomeClass(System::ComponentModel::IContainer container);
....
[DefaultValue(NULL)]
__property String* get_Kind();
[DefaultValue(NULL)]
__property String* set_Kind(String* value);
....
// other properties and methods
};

This class gets compiled into a component library. After dropping this
component on
a form (in C Sharp), the designer adds this line to the InitializeComponent
method of the form:

this.someClass1.Kind = null;

while I explicitly stated that that's the default value. BTW, it works as
expected with other types
like int, short, ...

I don't get it.
I am not using VS.NET 2003. It might be solved already (if it's a bug).

regards,
Bram.
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
Bram,

microsoft.public.dotnet.languages.vc is a better group for C++
questions.

Now the IDE keeps inserting null-assignments for
the string properties, while I've specified that NULL is
the default value. Other types work well.


Can you post your code?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 15 '05 #3
Bram,
[DefaultValue(NULL)]


Since NULL is defined as 0, that compiles down to [DefaultValue(0)]
using the int constructor. And to managed code, 0 != null.

I tried some other possibilities, but wasn't able to get the same as
[DefaultValue(null)] does in C#. That's partly due to a compiler bug.

I suggest you re-post your problem to the VC newsgroup, where it's
more likely to be seen by people who know this stuff.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #4

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

Similar topics

0
by: Craig Schneider | last post by:
// Is there any way to override the XML Serialization of the following SimpleClass // to turn off the DefaultValue of a boolean? Sure, I can override the DefaultValue from // true to false, but...
1
by: Mark | last post by:
How do I write the following code to set the default value? Me!xNum.DefaultValue = Me!XCurrency.DefaultValue = Me!XDate.DefaultValue = Me!XString.DefaultValue = Can I just put all the lines...
5
by: bbrik | last post by:
Hi, I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a...
1
by: RR | last post by:
Hi, I want to set the defaultvalue of a property in a class. I know this is possible by the DefaultValue Attribute like this: public class Test { public Test(){}
5
by: schneider | last post by:
Hello, Have an issue with a property using the DefaultValue(True) attribute. Imports System.ComponentModel Public Class Class1 Private m_testValue As Boolean
6
by: Meelis Lilbok | last post by:
Hi Why does property default value not work? When i start my application and dont set value from properties window the value is always "nothing". Whats the point off DefualtValue then? ...
3
by: MLH | last post by:
On frmVehicleEntryForm... I wanted to change the DefaultValue property of one of my textbox controls on a form from within code. I wanted the setting to be no setting - as if nothing had ever...
10
by: tony | last post by:
Hello!! I have some demo programs written in C# and they have this construction "" see below. I haven't seen this before so what does it mean ? public bool ShowDropDownButtons { get {...
25
by: kstevens | last post by:
I have a sub to determine if overtime has come into play yet on a certain job. If (preapproved) overtime has started then the next (subform) record can automatically be populated from a query...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.