fart_boy21
asked on
string data type
hi,
Is string a primitive data type in C#? If it is not, why it is a keyword? it comes out in bold when you enter "string" in the editor. In Java, it is part of java.lang.String and not a keyword.(it has a capital S)
thanks.
Is string a primitive data type in C#? If it is not, why it is a keyword? it comes out in bold when you enter "string" in the editor. In Java, it is part of java.lang.String and not a keyword.(it has a capital S)
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Excellent point, Jarodtweiss!
Although the fact that the Equals operator is overriden is not in *itself* significant. Other .NET System classes offer this functionality (for example, System.DateTime), and you can implement this feature in your own classes. How about the fact that System.String is immutable? That is, once an instance of the object has been created, it cannot be modified - you can only create a new string (System.Text.StringBuilder was designed to allow for this), of course System.DateTime is the same way, so I don't know how relative this is either.
Although the fact that the Equals operator is overriden is not in *itself* significant. Other .NET System classes offer this functionality (for example, System.DateTime), and you can implement this feature in your own classes. How about the fact that System.String is immutable? That is, once an instance of the object has been created, it cannot be modified - you can only create a new string (System.Text.StringBuilder
eternal_21, there is a difference between String and DateTime beacause DateTime is also an elementary data type, inheriting (inplicitely) from ValueType, but String is the only elementary data type which is a class.
It is the only point I wanted to focus on.
It is a class but act as it was a normal elementary data type (or so...)
It is the only point I wanted to focus on.
It is a class but act as it was a normal elementary data type (or so...)
C# - Works:
int x = 5;
Console.WriteLine(x.ToStri
Java - Does not work because there are no methods associated with int:
int x = 5;
System.out.println(x.toStr