Re: regex syntax
- From: Oliver Sturm <oliver@xxxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 10:14:11 +0100
jg wrote:
I did find the pattern string getting too huge. So I started to split date pattern into 3 components before using them to compose the final pattern, although I did not use the string format method.
Well, if you ask me, you should always use String.Format when putting together strings from more than two parts. A String.Format call can create an arbitrarily complicated string in one operation, while a concatenation a + b + c takes two operations at least. Strings are immutable in .NET, so a + b + c will end up allocating several new strings before the final result is ready.
The argument against this is that the compiler might get rid of some of the overhead for you, at least when a, b and c are static strings. But I don't like to depend on that, especially when the String.Format call is usually so much better readable:
"At " + time.ToString() + ", the user " + user + "had a problem accessing the " + resource + "resource."
String.Format("At {0}, the user {1} had a problem accessing the {2} resource.", time, user, resource);
Oliver Sturm -- omnibus ex nihilo ducendis sufficit unum Spaces inserted to prevent google email destruction: MSN oliver @ sturmnet.org Jabber sturm @ amessage.de ICQ 27142619 http://www.sturmnet.org/blog .
- Follow-Ups:
- Re: regex syntax
- From: Jon Skeet [C# MVP]
- Re: regex syntax
- From: jg
- Re: regex syntax
- References:
- regex syntax
- From: jg
- Re: regex syntax
- From: Oliver Sturm
- Re: regex syntax
- From: jg
- Re: regex syntax
- From: jg
- Re: regex syntax
- From: Oliver Sturm
- Re: regex syntax
- From: jg
- regex syntax
- Prev by Date: Re: Template for User requirement and System design documentation
- Next by Date: Re: dotnet 2.0: Generic programming
- Previous by thread: Re: regex syntax
- Next by thread: Re: regex syntax
- Index(es):
Relevant Pages
|