|
What is the value of using IDictionary here?
Started by oo on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
}
You can use it like this:
Dictionary<string, string> a = new Dictionary<string, string>(); SortedDictionary<string, string&....
A method like this:
void DoSomething(IDictionary<string, string> d) { //...
|
|
Quick one; am I right in thinking that passing a string to a method 'as a CONST' involves more overhead than passing a string as a 'VAR'? The compiler will get Delphi to make a copy of the string and then pass the copy, if the string parameter is declared...
Started by robsoft on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
In both cases....
You will get a bigger const or var in your case .
Using const saves you the overhead of incrementing/decrementing the refcounter for the string that you use.
The compiler won't make a copy of the string when using const afaik.
|
|
Object obj = "Hello"; string str1 = (string)obj; string str2 = obj.ToString();
What is the difference between (string)obj and obj.ToString() ?
Started by Praveen on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Which is obj itself when obj is a string .
Obj.ToString() gets a string representation of obj by calling the ToString() method.
Obj must already be a string for this to succeed.
string)obj casts obj into a string .
|
Ask your Facebook Friends
|
I'm interested in both style and performance considerations. My choice is to do either of the following ( sorry for the poor formatting but the interface for this site is not WYSIWYG ):
One: string value = "ALPHA"; switch ( value.ToUpper() ) { case "ALPHA...
Started by Dan7el on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
In fact, it will throw an ....
One thing to consider is would you need the valuesThe second option is marginally faster, as the first option may require a full string comparison range.
When switching on a string value versus an enum.
|
|
I was recently trying to explain to a programmer why, in ASP.Net, they should create HTMLControls instead of creating HTML strings to create Web pages.
I know it is a better way of doing things, but I really couldn't give concrete reasons, other than,...
Started by Rich on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
One big advantage: Writing HTML as a string is hugely prone to human.
From a code that might break xhtml compliance.
The resulting manual HTML is such a mess that it's impractical to maintain as a string.
|
|
I have two LinkedList objects that are always of the same size. I want to compare them to see if they are identical in content. What are the general performance and style implications of creating a ListIterator for each list and using a while hasNext ...
Started by rush340 on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The code is:
public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof List)) return false; ListIterator<E> e1 = listIterator... .
As it turns out AbstractList.equals() (which LinkedList uses) will do this automatically so use that .
|
|
<div style="margin: 2px; float: right; width: 300px; height: 250px;style="width:200px; float:left;">
</div> <div>string versus String !
I have a question (a little embarrassing because I see it so late), what is the difference between...
Started by q12 on
, 3 posts
by 2 people.
Answer Snippets (Read the full thread at xtremedotnettalk):
Same way that int in C#.
Runtime (CLR) while string is just the C# keyword for the same thing.
|
|
I've discovered that std::string's are very slow compared to old-fashioned null-terminated strings, so much slow that they significantly slow down my overall program by a factor of 2.
I expected STL to be slower, I didn't realise it was going to be this...
Started by Tim Cooper on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
If you are experiencing performance to read a std::string commandline parameter, then a lock would be needed even just to read the string, and the memory is freed.)....
string is as efficient as char*, but with the added protection.
|
|
In Python, the where and when of using string concatenation versus string substitution eludes me. As the string concatenation has seen large boosts in performance, is this (becoming more) a stylistic decision rather than a practical one?
For a concrete...
Started by gotgenes on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Concatenation is useful when you....
In fact, your string interpolation version.
String interpolation allows you to easily add formatting.
I only use concatenation if I'm building a string up in say.
I use substitution wherever I can.
|
|
I'm a little confused about when to use single quoted strings versus double quoted strings. I've noticed that if I put a variable inside a single quoted string, it doesn't get interpreted. Also, if I use a newline character in a double quoted string, ...
Started by Tucker on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Single-quoted strings are treated it is supplementary information....
Is this because the '\ ' is interpreted as a special character in the double quote string but in the single quoted string the characters are preserved as is?
Yes.
|