Question: String concatenation in a loop. I get this bug when i tested my project in klocwork. i am concatenating many strings in loop is it a big mistake .

```
for(int j=0;j<nAttr;j++)
{
    builder = new StringBuilder();
    size=rnd.Next(1,10);
    for(int k=0; k<size; k++)
    {
        ch = Convert.ToChar(Convert.ToInt32(26 * rnd.NextDouble() + 65)) ;
        if(ch=='[' || ch==']')
            j--;
        else
            builder.Append(ch); 
    }
    strXml+=" "+builder.ToString();//here the bug arises 
    strXml+="="+"\"";

```

i also found this bug when i tested 

Class/struct data member is hidden by a local variable what does it mean 

```
private void TraverseValues(XmlNode n,ArrayList arr)
{
    if(n.HasChildNodes )
    {   
        for(int i=0;i<n.ChildNodes.Count;i++)
        {
            if(n.ChildNodes[i].Name=="#text")
                arr.Add(n.ChildNodes[i].InnerText );
            else    
                TraverseValues(n.ChildNodes[i],arr)//here the code arises 

```

i completed my project .it works fine then i tested my product with klocwork it suggested these bugs .but i am not able to understand y it says it has critical error in code

Answer: 
Klickwork creates a static analysis application.

I think Arunachalam refers to some static analysis assertion as "bug".

When strXml is of string type then it would be possible that static analysis will show `strXml+=" "+builder.ToString();` as bad code (a "bug").

From the code posted it is definitely not bug in the core .NET Library.
You might want to have

```
if (ch=='[' || ch==']')
  k--;

```

But even this doesn't make sense, since you will only get characters from 'A' to 'Z'.