473,385 Members | 1,772 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,385 software developers and data experts.

Difference between string and String?

I notice there are many terms in the .NET Framework like string and String.
What's the difference? Which should I use?

I also see int and Int32. They are the same?

Thanks,
Ron
Sep 1 '06 #1
8 17530
Ronald S. Cook wrote:
I notice there are many terms in the .NET Framework like string and String.
What's the difference? Which should I use?

I also see int and Int32. They are the same?
They are the same.

int and string are types in the C# language.

Int32 and String are types in the .NET framework.

And the C# types are mapped to the .NET types.

My wording. MS may explain it differently.

Arne
Sep 1 '06 #2
*"Ronald S. Cook" <rc***@westinis.comwrote in message
news:eE**************@TK2MSFTNGP06.phx.gbl...
*I notice there are many terms in the .NET Framework like string and String.
* What's the difference? Which should I use?
*
* I also see int and Int32. They are the same?
*
* Thanks,
* Ron
*
*

Ron,

They're the same.
String comes from the .NET class System.String and string (lower case) is a
C# alias for System.String.
I often see devs interchange the .NET and C# aliases for various data types;
not sure why though.

-MH
Sep 1 '06 #3
They do seem to be different...
The Split method is not accessible when trying to use it as string.Split but
it is as String.Split
If they are the same how could that be?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W

"Michael" <mh***@domain.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
*"Ronald S. Cook" <rc***@westinis.comwrote in message
news:eE**************@TK2MSFTNGP06.phx.gbl...
*I notice there are many terms in the .NET Framework like string and
String.
* What's the difference? Which should I use?
*
* I also see int and Int32. They are the same?
*
* Thanks,
* Ron
*
*

Ron,

They're the same.
String comes from the .NET class System.String and string (lower case) is
a C# alias for System.String.
I often see devs interchange the .NET and C# aliases for various data
types; not sure why though.

-MH


Sep 1 '06 #4
Split is an instance method, not a static member. So at least on 2.0, you
can not do "string.Split" or "String.Split". You can with an string
instance.

--
William Stacey [MVP]

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:O6**************@TK2MSFTNGP02.phx.gbl...
| They do seem to be different...
| The Split method is not accessible when trying to use it as string.Split
but
| it is as String.Split
| If they are the same how could that be?
|
|
| <%= Clinton Gallagher
| NET csgallagher AT metromilwaukee.com
| URL http://clintongallagher.metromilwaukee.com/
| MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W
|
| "Michael" <mh***@domain.comwrote in message
| news:%2****************@TK2MSFTNGP05.phx.gbl...
| *"Ronald S. Cook" <rc***@westinis.comwrote in message
| news:eE**************@TK2MSFTNGP06.phx.gbl...
| *I notice there are many terms in the .NET Framework like string and
| String.
| * What's the difference? Which should I use?
| *
| * I also see int and Int32. They are the same?
| *
| * Thanks,
| * Ron
| *
| *
| >
| Ron,
| >
| They're the same.
| String comes from the .NET class System.String and string (lower case)
is
| a C# alias for System.String.
| I often see devs interchange the .NET and C# aliases for various data
| types; not sure why though.
| >
| -MH
| >
| >
|
|
Sep 1 '06 #5
Most of the code I have seen uses int for Int32,
and string for String. But the choice is yours.

In most cases using the alias types will be identical
to the CLR type. However, value types like int
(Int32), may not. Consider the following two loops:

for (int i = 0; i < int.MaxValue; i++)
{
// Loop runs to Int32.MaxValue on 32-bit cpus.
// Loop runs to Int64.MaxValue on 64-bit cpus.

// The big difference here is this loop could have
// more loops on 64-bit cpus.
// Can your program tolerate this?
}

// Using CLR Types
for (Int32 i = 0; i < Int32.MaxValue; i++)
{
// This loop will have the same number of iterations
// on 32-bit or 64 bit cpus.
}

Personally I use the CLR types exclusively. So
when I say Int32 i = 9; I know will will be 32bits
and not 64 bits.

Russell Mangel
Las Vegas, NV
Sep 1 '06 #6
No, according to the c# spec (3.4.2 and 4.1.4), int is System.Int32
*always* (lessons learnt from the past...). IntPtr.Size changes to
match the OS, however.

Marc

Sep 1 '06 #7
Russell Mangel <ru*****@tymer.netwrote:
Most of the code I have seen uses int for Int32,
and string for String. But the choice is yours.

In most cases using the alias types will be identical
to the CLR type. However, value types like int
(Int32), may not. Consider the following two loops:

for (int i = 0; i < int.MaxValue; i++)
{
// Loop runs to Int32.MaxValue on 32-bit cpus.
// Loop runs to Int64.MaxValue on 64-bit cpus.

// The big difference here is this loop could have
// more loops on 64-bit cpus.
// Can your program tolerate this?
}
Any evidence for this? I don't believe it's the case at all. int
*always* means Int32 as far as I've ever seen in the standard.
// Using CLR Types
for (Int32 i = 0; i < Int32.MaxValue; i++)
{
// This loop will have the same number of iterations
// on 32-bit or 64 bit cpus.
}

Personally I use the CLR types exclusively. So
when I say Int32 i = 9; I know will will be 32bits
and not 64 bits.
Would you feel differently if the above was proved not to be true? The
spec is very clear on the matter. For example, from 11.1.5 (ECMA
numbering for C# 2.0):

<quote>
The int type represents signed 32-bit integers with values from
=3F2147483648 to 2147483647, inclusive.
</quote>

--
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
Sep 4 '06 #8

Russell Mangel wrote:
Most of the code I have seen uses int for Int32,
and string for String. But the choice is yours.

In most cases using the alias types will be identical
to the CLR type. However, value types like int
(Int32), may not. Consider the following two loops:

for (int i = 0; i < int.MaxValue; i++)
{
// Loop runs to Int32.MaxValue on 32-bit cpus.
// Loop runs to Int64.MaxValue on 64-bit cpus.

// The big difference here is this loop could have
// more loops on 64-bit cpus.
// Can your program tolerate this?
}

// Using CLR Types
for (Int32 i = 0; i < Int32.MaxValue; i++)
{
// This loop will have the same number of iterations
// on 32-bit or 64 bit cpus.
}
Beg to differ. Running on a quad Xeon (EM64T) box, with Windows Server
2003 64-bit Enterprise Edition:

Console.WriteLine("int.MaxValue = " + int.MaxValue);
Console.WriteLine("Int32.MaxValue = " + Int32.MaxValue);
Console.WriteLine("Int64.MaxValue = " + Int64.MaxValue);

int.MaxValue = 2147483647
Int32.MaxValue = 2147483647
Int64.MaxValue = 9223372036854775807

And Jon's already pointed out the spec reference.

Michael

Sep 5 '06 #9

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

Similar topics

26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
17
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
12
by: Tee | last post by:
String Builder & String, what's the difference. and when to use which ? Thanks.
6
by: Mark Kamoski | last post by:
Hi Everyone-- Please help. What is the difference between a Field and a Property? Here is the context. In the VS.NET 2002 documentation, in the "String Members" section, we have the...
9
by: Anoj | last post by:
Hi All, is there any performance difference between + and & operator while concating string litrels. which one is better and why?? Thanx
7
by: Bart_D | last post by:
Hi, Can anybody explain me what's the difference between for example: imports system.data implements ICallbackEventHandler inherits System.Web.UI.Page Thanks Bart
7
by: Bruce One | last post by:
What is the difference between String and string in C#? What can u do with string that you cant do with String, vice versa?
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
6
by: =?Utf-8?B?SmVmZg==?= | last post by:
I thought this would already be covered here, but my search turned up nothing. In VS2005, if I use "String" to define a new variable/class, it colors it in the Aqua color as it does other...
45
by: anto frank | last post by:
hi friends, is ther any difference in array in c and array in c++?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.