I have a property for a control ( source code not available) . The property
accepts single char as value.. so I can set it to '/' or ':' or anything
like that...At initialize of my From I want this property to be set to a
empty literal. I am able to do this at design time using VS.NET property
box. This works for controls created at design time, but for some controls I
create at run-time I want to do the same at Form_load..
VJ 9 119225
There is no "empty character literal", because every possible value
for a char type is one character long. You can have zero length
strings ("") but not zero-length characters, e.g. this will not
compile:
char ch = ''; // doesn't work
The closest you can get is a space (' ') or a null character ('\0',
ASCII zero).
P.
VJ <vi********@yahoo.com> wrote: I have a property for a control ( source code not available) . The property accepts single char as value.. so I can set it to '/' or ':' or anything like that...At initialize of my From I want this property to be set to a empty literal. I am able to do this at design time using VS.NET property box. This works for controls created at design time, but for some controls I create at run-time I want to do the same at Form_load..
There's no such thing as an "empty" character, any more than there's an
"empty integer". What's the property used for? Character 0 (the "null"
character) *might* be an appropriate start value, but it's hard to say
without more information.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"VJ" <vi********@yahoo.com> schrieb im Newsbeitrag
news:uP*************@TK2MSFTNGP10.phx.gbl... I have a property for a control ( source code not available) . The property accepts single char as value.. so I can set it to '/' or ':' or anything like that...At initialize of my From I want this property to be set to a empty literal. I am able to do this at design time using VS.NET property box. This works for controls created at design time, but for some controls I create at run-time I want to do the same at Form_load..
VJ
If you can do it with VS.NET, simply do it and check the value while
runtime.
The you know, what character it is and set it in code.
Just a technical note about this: The reason that you can have empty strings
is that a string is an array of char with a null terminator. That is, a
string is actually (in memory) one char longer than the actual string,
including the null terminator. A char, on the other hand, is not an array,
but a single char.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Paul E Collins" <fi******************@CL4.org> wrote in message
news:di**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com... There is no "empty character literal", because every possible value for a char type is one character long. You can have zero length strings ("") but not zero-length characters, e.g. this will not compile:
char ch = ''; // doesn't work
The closest you can get is a space (' ') or a null character ('\0', ASCII zero).
P.
that is not true.
..net strings are not null terminated. the reason why you can have an
empty string is because it's perfectly legal to have a 0-length array.
Kevin Spencer wrote: Just a technical note about this: The reason that you can have empty strings is that a string is an array of char with a null terminator. That is, a string is actually (in memory) one char longer than the actual string, including the null terminator. A char, on the other hand, is not an array, but a single char.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Paul E Collins" <fi******************@CL4.org> wrote in message news:di**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com... There is no "empty character literal", because every possible value for a char type is one character long. You can have zero length strings ("") but not zero-length characters, e.g. this will not compile:
char ch = ''; // doesn't work
The closest you can get is a space (' ') or a null character ('\0', ASCII zero).
P.
Ok I got this one... The property had a corresponding Int property which if
I set to zero then it achieved the same thing as setting to nothing using
VS.NET property window...
Thanks all for your input..
VJ
"VJ" <vi********@yahoo.com> wrote in message
news:uP*************@TK2MSFTNGP10.phx.gbl... I have a property for a control ( source code not available) . The property accepts single char as value.. so I can set it to '/' or ':' or anything like that...At initialize of my From I want this property to be set to a empty literal. I am able to do this at design time using VS.NET property box. This works for controls created at design time, but for some controls I create at run-time I want to do the same at Form_load..
VJ
Well, Daniel, you made me do my homework. In fact, we were both wrong. The
truth is a bit more complex. It depends on the implementation used. If C# or
C++ is used, it is indeed an array of WCHAR. If C is used, it is a
null-terminated string.
Now for some aspirin...
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Daniel Jin" <sh********@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... that is not true.
.net strings are not null terminated. the reason why you can have an empty string is because it's perfectly legal to have a 0-length array.
Kevin Spencer wrote: Just a technical note about this: The reason that you can have empty strings is that a string is an array of char with a null terminator. That is, a string is actually (in memory) one char longer than the actual string, including the null terminator. A char, on the other hand, is not an array, but a single char.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Paul E Collins" <fi******************@CL4.org> wrote in message news:di**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com... > There is no "empty character literal", because every possible value for > a > char type is one character long. You can have zero length strings ("") > but > not zero-length characters, e.g. this will not compile: > > char ch = ''; // doesn't work > > The closest you can get is a space (' ') or a null character ('\0', > ASCII > zero). > > P. > >
I'm not sure what you mean by "depends on implemenation". according to Jon
Skeet's article on .NET string though, it is indeed null terminated
internally for p/invoke. so I was wrong, which makes my original point a
little inconsequential, that you don't need null termination for empty
strings, a 0-length array should do just fine.
"Kevin Spencer" wrote: Well, Daniel, you made me do my homework. In fact, we were both wrong. The truth is a bit more complex. It depends on the implementation used. If C# or C++ is used, it is indeed an array of WCHAR. If C is used, it is a null-terminated string.
Now for some aspirin...
-- HTH,
Kevin Spencer Microsoft MVP ..Net Developer Ambiguity has a certain quality to it.
"Daniel Jin" <sh********@yahoo.com> wrote in message news:11*********************@g43g2000cwa.googlegro ups.com... that is not true.
.net strings are not null terminated. the reason why you can have an empty string is because it's perfectly legal to have a 0-length array.
Kevin Spencer wrote: Just a technical note about this: The reason that you can have empty strings is that a string is an array of char with a null terminator. That is, a string is actually (in memory) one char longer than the actual string, including the null terminator. A char, on the other hand, is not an array, but a single char.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Paul E Collins" <fi******************@CL4.org> wrote in message news:di**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com... > There is no "empty character literal", because every possible value for > a > char type is one character long. You can have zero length strings ("") > but > not zero-length characters, e.g. this will not compile: > > char ch = ''; // doesn't work > > The closest you can get is a space (' ') or a null character ('\0', > ASCII > zero). > > P. > >
By the way, just for your information C# 2.0 has the concept of
nullable types. There is still no such thing as the "empty character",
but in C# 2.0 you can say:
char? emptyChar = null;
which isn't quite what you were after, but I thought I'd mention it
because it's sort of related. :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christian Kandeler |
last post by:
Hi,
if I want to store the string "123456" in a variable of type char, I can
do it like this:
char s = "123456";
Or like this:
char s = { '1', '2', '3', '4', '5', '6', '\0' };
|
by: Dakkar |
last post by:
when i write something like this
char arr = {'a','b','''}
its giving the
Error 2 Empty character literal
error how can i add the ' character to an
char array...
|
by: Eranga |
last post by:
What is empty character literal and how can we get rid of it.
I want to check whether the text box is empty so I use
if (TextBox1.Text == '' ) Why cant I do this?
*** Sent via Developersdex...
|
by: gvanosdol |
last post by:
When on my development machine, I can execute the code in the subject
(string strVarArr = strVar.Split('x');) without any problems. When I
try to move the code to my server, I get "CS1011: Empty...
|
by: Ivan |
last post by:
Hi,
What is the best syntax to use a char to index into an array.
///////////////////////////////////
For example
int data;
data = 1;
|
by: Sami |
last post by:
string = "" or string = string.Empty?
should is the proper way?
Sami
|
by: =?ISO-8859-2?Q?Boris_Du=B9ek?= |
last post by:
Hi,
I have trouble defining a macro - see the following code:
#define LETTER_STRAIGHT(let) let = L'#let'
enum Letter {
LETTER_STRAIGHT(A),
LETTER_STRAIGHT(B),
LETTER_STRAIGHT(C),
|
by: zaimoni |
last post by:
I've already calculated that the following are valid and should not
error, as both just end up with the character literal 'A' being their
control expression. The unspecified value of the char*...
|
by: zman77 |
last post by:
Hello,
I have a bunch of Image Buttons in my code. When I leave them as they are, I can build my project without problems. However, when I add OnClick to an image button, I get the error:
Too...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |