0

I have a code like this:

StringBuilder systemCondition = new StringBuilder();
systemCondition.Append("^(");
systemCondition.Append(Regex.Escape(this.Class));
systemCondition.Append(" : ");
systemCondition.Append(Regex.Escape(this.Instance));
systemCondition.Append(")$");
m_afc.QualifiedInstanceFilter = systemCondition.ToString();

Can any body tell me whats wrong here? Then what about this code

2
  • 2
    You are returning whole different stuff, that is why you see different string. You didn't optimize the code, you changed the logic itself. Commented Aug 25, 2011 at 7:18
  • 1
    ricky - what? Your last comment didn't make much sense. Commented Aug 25, 2011 at 7:43

1 Answer 1

1

If you just want more elegant code in one line, why not this?

m_afc.QualifiedInstanceFilter = string.Format("^({0} : {1})$", Regex.Escape(this.Class), Regex.Escape(this.Instance));
Sign up to request clarification or add additional context in comments.

3 Comments

What about the code? Don't know, you didn't really ask any question. String is totally fine, StringBuilder should be used only when you append to the string in a loop or something like that.
ricky throwing code at us won't help. You have to explain what exactly is wrong.
Comments are not meant for code. Please add it to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.