|
In C# what is the difference between String and string? (note the case)
Also, what are the guidelines for the use of each?
Started by Lance Fisher on
, 16 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
string....
As far as guidelines, I think it's generally recommended to use string any time you're referring to an object.
System.Int32.
It's like int vs.
So technically, there is no difference.
string is an alias for System.String .
|
|
Hello,
I have a question about comparing a string with the empty string in Java. Is there a difference, if I compare a string with the empty string with == or equals? For example:
String s1 = "hi"; if (s1 == "")
or
if (s1.equals(""))
I know that one should...
Answer Snippets (Read the full thread at stackoverflow):
If you create the string with
new String("")
Then it will never match "" with the equals operator, as shown below:
String one = ""; String two = new String....
It's going to depend on if the string is a literal or not.
|
|
Duplicate of this question .
I'm learning C++ at the moment, and I'm coming across a lot of null-terminated strings. This has got me thinking, what makes more sense when declaring pointers:
char* string
or
char *string
? To me, the char* format makes ...
Started by Skilldrick on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
Just offering another POV
In most cases, std::string str * string;
Consider, if Dennis Ritchie (designer od the C language) instead of using the '*' character had used a keyword 'ptr', we would....
Simplify definitions a few times as well.
|
Ask your Facebook Friends
|
Hi,
I have an json output of the following (ignore the escape characters)
"{\"sEcho\":1,\"iTotalRecords\":10,\"iTotalDisplayRecords\":10,\"aaData\":[{\"Job\":\"developer\",\"Name\":\"kurt\"},{\"Job\":\"plumber\",\"Name\":\"john\"}]}"
which i get from
...
Started by kjm on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
My guess is that instead of a Person object, you'd have to create a List for each Person, putting string MakeJsonLikeStr(object o) { string json = JsonConvert.SerializeObject(o); return json.Replace.
|
|
In C# the string keyword (highlighted in Visual Studio as a data type) is just a shortcut to the String class right?
In that case, it would be the same to use either while coding from the semantic point of view. However, is it the same from the performance...
Started by Toto on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Lowercase "string" is preferred in most projects due to the syntax highlighting
string is just an alias....
There are no performance implications either way.
string and String are identical in all ways (except the uppercase "S").
|
|
In asp.net MVC I have a search action in my controller and I am trying to decide If I should pass the query to my repository as a string
public ActionResult Search(string query) { return View(_repository.ListPeople(query)); }
or as individual parameters...
Started by Graham on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Looking at it from a separation of concerns.
Repository be in charge of getting data, it shouldn't have to do any kind of parsing of a query string take on the responsibility of parsing a query string.
|
|
In T-SQL, how would you check if a string doesn't contain another string?
I have an nvarchar which could be "Oranges Apples".
I would like to do an update where, for instance, a columm doesn't contain "Apples".
How can this be done?
Started by Dofs on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
WHERE NOT (someColumn LIKE "%Apples%")
Or alternatively, you could use this:
WHERE CHARINDEX(N'Apples', someColumn) = 0
Not sure which one performs better - you gotta test it! :-)
Marc
UPDATE: the performance seems to be pretty much on a par with the... .
|
|
I have following data:
Dictionary<string,string> dctParameters = new Dictionary(){ {"a",var1},{"b",var2},{"c",var3},.... }
I want to join the "dctParameters" into a querystring.
What's the fastest / best among the following ways? Can you think you...
Started by Billy on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
How about an extension method as a variation....
I personally would go with the third method and precalculate the total end string length to feed into the StringBuilder constructor.
That requires parsing through your format string.
|
|
Most of the developers on my current project use a (to me) strange way to check for empty strings in ECMAScript:
if (theString.length == 0) // string is empty
I would normally write this instead:
if (theString == "") // string is empty
The latter version...
Started by Thomas Müller on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
...so unless you know that theString is actually a string , you might end up causing problems of the strict equal ( ....
But there's another reason == "" ...
Between an empty string literal "" and several other strings ( " " , '"' ).
|
|
Hi everyone,
I am programming in C++ and I'm not sure how to achieve the following:
I am copying a file stream to memory (because I was asked to, I'd prefer reading from stream), and and then trying to access its values to store them into strings and ...
Started by Val on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Example:
// Load string from character buffer std::string input_string(buffer, buffer + length)....
A, b; string c, d; iss >> a; iss >> b; iss >> c; iss >> d;
The way something for "parser generator".
|