473,490 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Q: String (Capital S) vs string (small s)?

Hi

What is the difference by using String myString or string myString when
declaring a string ?

Regards
Martin
Nov 8 '06 #1
11 2823
None.

'string' is an alias for the 'String' class. Just as 'int' is an alias for
the Int32 structure, and so on.

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi

What is the difference by using String myString or string myString when
declaring a string ?

Regards
Martin

Nov 8 '06 #2
Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.

On Nov 8, 4:18 pm, "Marina Levit [MVP]" <some...@nospam.comwrote:
None.

'string' is an alias for the 'String' class. Just as 'int' is an alias for
the Int32 structure, and so on.

"Martin Arvidsson" <yeahri...@ms.comwrote in messagenews:%2****************@TK2MSFTNGP03.phx.gb l...
Hi
What is the difference by using String myString or string myString when
declaring a string ?
Regards
Martin- Hide quoted text -- Show quoted text -
Nov 8 '06 #3
No, I am fairly certain the compiler knows to translate one to the other.

<gb****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.

On Nov 8, 4:18 pm, "Marina Levit [MVP]" <some...@nospam.comwrote:
>None.

'string' is an alias for the 'String' class. Just as 'int' is an alias
for
the Int32 structure, and so on.

"Martin Arvidsson" <yeahri...@ms.comwrote in
messagenews:%2****************@TK2MSFTNGP03.phx.g bl...
Hi
What is the difference by using String myString or string myString when
declaring a string ?
Regards
Martin- Hide quoted text -- Show quoted text -

Nov 8 '06 #4
int is mapped to System.Int32 so other then typing more you won't accomplish
much :)

Regards,
John

<gb****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.

On Nov 8, 4:18 pm, "Marina Levit [MVP]" <some...@nospam.comwrote:
>None.

'string' is an alias for the 'String' class. Just as 'int' is an alias
for
the Int32 structure, and so on.

"Martin Arvidsson" <yeahri...@ms.comwrote in
messagenews:%2****************@TK2MSFTNGP03.phx.g bl...
Hi
What is the difference by using String myString or string myString when
declaring a string ?
Regards
Martin- Hide quoted text -- Show quoted text -

Nov 8 '06 #5
<gb****@gmail.comwrote:
Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.
I use the keyword names in my code for the sake of keyword higlighting
- but for library methods, you should use the type name (eg
Convert.ToInt32) so that it's not tailored to one particular .NET
language.

--
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
Nov 8 '06 #6
That's sound advice. Is that the reason these aliases exist in C#? To
provide a way to refer to objects in a non-language specific way?

On Nov 8, 5:11 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
<gbg...@gmail.comwrote:
Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.I use the keyword names in my code for the sake of keyword higlighting
- but for library methods, you should use the type name (eg
Convert.ToInt32) so that it's not tailored to one particular .NET
language.

--
Jon Skeet - <s...@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
Nov 8 '06 #7
Hi Jon,

I do the same for keyword highlighting, but I'm not clear on why I shouldn't
in library methods. Once compiled to CIL, I don't see how it would matter.

Are you suggesting that I use Convert.ToInt32 instead of casting to (int),
even in cases where I know that an explicit cast exists?

--
Dave Sexton

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
<gb****@gmail.comwrote:
>Is there a benefit to using one over the other? I've sometimes found
myself wondering if I should declare all my int's as Int32's.

I use the keyword names in my code for the sake of keyword higlighting
- but for library methods, you should use the type name (eg
Convert.ToInt32) so that it's not tailored to one particular .NET
language.

--
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

Nov 8 '06 #8
Dave Sexton <dave@jwa[remove.this]online.comwrote:
I do the same for keyword highlighting, but I'm not clear on why I shouldn't
in library methods. Once compiled to CIL, I don't see how it would matter.

Are you suggesting that I use Convert.ToInt32 instead of casting to (int),
even in cases where I know that an explicit cast exists?
No, I'm suggesting that you write methods with names of ToInt32 and
ToSingle rather than ToInt and ToFloat. I wasn't talking about
implementation, just naming - sorry to confuse :(

--
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
Nov 8 '06 #9
Hi Jon,

Ok, that makes more sense!

--
Dave Sexton

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Dave Sexton <dave@jwa[remove.this]online.comwrote:
>I do the same for keyword highlighting, but I'm not clear on why I
shouldn't
in library methods. Once compiled to CIL, I don't see how it would matter.

Are you suggesting that I use Convert.ToInt32 instead of casting to (int),
even in cases where I know that an explicit cast exists?

No, I'm suggesting that you write methods with names of ToInt32 and
ToSingle rather than ToInt and ToFloat. I wasn't talking about
implementation, just naming - sorry to confuse :(

--
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

Nov 8 '06 #10
Is this alias something internal to the compiler, or declared somewhere in
code?

In other words, could I use this aliasing feature for my own types?

Kevin

"Marina Levit [MVP]" <so*****@nospam.comwrote in message
news:eM**************@TK2MSFTNGP03.phx.gbl...
None.

'string' is an alias for the 'String' class. Just as 'int' is an alias for
the Int32 structure, and so on.

"Martin Arvidsson" <ye*******@ms.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Hi

What is the difference by using String myString or string myString when
declaring a string ?

Regards
Martin


Nov 19 '06 #11
Kevin Frey <ke**********@hotmail.comwrote:
Is this alias something internal to the compiler, or declared somewhere in
code?

In other words, could I use this aliasing feature for my own types?
You can alias types with the "using" directive at the start of a file,
but you can't add your own "global" aliases.

--
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
Nov 20 '06 #12

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

Similar topics

9
3219
by: Agent Mulder | last post by:
My funky new compiler does not understand string, but it does understand String, so that this program gives the expected result: #include<iostream> #include<string> int main() { String...
1
36045
by: Ren? M?hle | last post by:
I have a psp script with a procedure just to run an update on one table. The Problem occurs when I try to compile this script with pspload: ORA-20006: "frsys_updatereport.psp": compilation...
0
5353
by: Hessam | last post by:
Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To do this have declared a private string variable...
4
11868
by: J. Oliver | last post by:
I am attempting to copy a portion of a string into another string. Say I have "abcdef" in string 'a' and want to copy only "bcd" into a new string 'b'. The following function came to mind: ...
5
1639
by: Ioannis Vranos | last post by:
When we assign a managed or unmanaged string literal to a String *, is a new String created implicitly in the managed heap? Or in other words, what happens when we assign a string literal to...
3
3313
by: Maileen | last post by:
Hi, How can we convert string^ to String or to LPCWSTR ? thx, Maileen
3
1390
by: Green | last post by:
Hi, I am reading about an article of user control at the following site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingpageletproperties.asp and i...
22
9693
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
2
26700
by: pbmanikandan | last post by:
Horrible error. I use a function called cleanse company name that "removes" some strings if present from a string that is passed to it. In a procedure, I do the following. INSERT into table1...
3
3261
by: ahd2008 | last post by:
Good day all, I am creating a new from for the purpose of allowing the Admin(s) to create new users. There is a filed for the password and another one to confirm the password. However, MS Access...
0
7108
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
7181
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
5445
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,...
1
4875
isladogs
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...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.